Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#160: Write unit tests for SQLSearch #174

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

aaronhktan
Copy link
Owner

Description

  • This commit adds tests for the SQLSearch class.
  • This commit fixes some logic in SegmentPinyin/SegmentJyutping involving
    glob characters, where invalid sequences before glob characters would
    not be added to the search term.
  • This commit fixes the parsing of the 'direct' field in sentence
    links. Since SQLite stores booleans as integers, QJsonValue::toBool()
    would always return "false", even if the stored value was 1.
  • This commit adds comparison of definitions and sentences when
    checking for equality in the Entry class.
  • This commit adds additional data members to operator<< in Entry et al.
  • This commit adds the ability to remove all database connections, which
    is useful on Windows since we cannot delete a database file that somebody
    is keeping a connection open to.

Part of a series of commits for #160.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Tested on all three platforms.

PASS	Executing test case TestSqlSearch
	Qt version: 5.15.12
	Qt build: Qt 5.15.12 (arm64-little_endian-lp64 shared (dynamic) release build; by Clang 15.0.0 (clang-1500.0.40.1) (Apple))
	QTest version: 5.15.12
PASS	Executing test function initTestCase
PASS	TestSqlSearch::initTestCase
	Execution took 0.038041 ms.
PASS	Executing test function searchSimplified
PASS	TestSqlSearch::searchSimplified
	Execution took 3.75446 ms.
PASS	Executing test function searchSimplifiedNoResults
PASS	TestSqlSearch::searchSimplifiedNoResults
	Execution took 1.11429 ms.
PASS	Executing test function searchTraditional
PASS	TestSqlSearch::searchTraditional
	Execution took 2.98029 ms.
PASS	Executing test function searchTraditionalNoResults
PASS	TestSqlSearch::searchTraditionalNoResults
	Execution took 0.9655 ms.
PASS	Executing test function searchJyutping
PASS	TestSqlSearch::searchJyutping
	Execution took 5.23442 ms.
PASS	Executing test function searchJyutpingNoResults
PASS	TestSqlSearch::searchJyutpingNoResults
	Execution took 1.93096 ms.
PASS	Executing test function searchPinyin
PASS	TestSqlSearch::searchPinyin
	Execution took 5.00858 ms.
PASS	Executing test function searchPinyinNoResults
PASS	TestSqlSearch::searchPinyinNoResults
	Execution took 1.70817 ms.
PASS	Executing test function searchEnglish
PASS	TestSqlSearch::searchEnglish
	Execution took 3.71446 ms.
PASS	Executing test function searchEnglishNoResults
PASS	TestSqlSearch::searchEnglishNoResults
	Execution took 0.59975 ms.
PASS	Executing test function searchAutoDetect
PASS	TestSqlSearch::searchAutoDetect
	Execution took 19.7345 ms.
PASS	Executing test function searchAutoDetectNoResults
PASS	TestSqlSearch::searchAutoDetectNoResults
	Execution took 2.96712 ms.
PASS	Executing test function searchUnique
PASS	TestSqlSearch::searchUnique
	Execution took 0.923375 ms.
PASS	Executing test function searchTraditionalSentences
PASS	TestSqlSearch::searchTraditionalSentences
	Execution took 0.373875 ms.
PASS	Executing test function cleanupTestCase
PASS	TestSqlSearch::cleanupTestCase
	Execution took 0.001458 ms.
	Test execution took 51.1339 ms.

Checklist:

  • My code follows the style guidelines of this project (black for Python
    code, .clang-format in the src/jyut-dict directory for C++)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have translated my user-facing strings to all currently-supported languages
  • I have made corresponding changes to the documentation

- This commit adds tests for the SQLSearch class.
- This commit fixes some logic in SegmentPinyin/SegmentJyutping involving
  glob characters, where invalid sequences before glob characters would
  not be added to the search term.
- This commit fixes the parsing of the 'direct' field in sentence
  links. Since SQLite stores booleans as integers, QJsonValue::toBool()
  would always return "false", even if the stored value was 1.
- This commit adds comparison of definitions and sentences when
  checking for equality in the Entry class.
- This commit adds additional data members to operator<< in Entry et al.
- On Windows, files can't be deleted if there is anything that
  has them open. By removing all the connections to the database,
  it can be deleted.
@aaronhktan aaronhktan added the maintenance Code quality, maintainability, tech debt label Mar 14, 2024
@aaronhktan aaronhktan added this to the 2024 Milestone 1 milestone Mar 14, 2024
@aaronhktan aaronhktan self-assigned this Mar 14, 2024
@aaronhktan aaronhktan merged commit 3bdfcbe into main Mar 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Code quality, maintainability, tech debt
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant