From 58d7e250c3c2b6cc494184373bb94bf39a166286 Mon Sep 17 00:00:00 2001 From: Loay Ghreeb Date: Mon, 23 Sep 2024 11:26:10 +0300 Subject: [PATCH] More test cases --- .../search/SearchToSqlConversionTest.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/search/SearchToSqlConversionTest.java b/src/test/java/org/jabref/logic/search/SearchToSqlConversionTest.java index 716c4b3098d..a5be0e7367b 100644 --- a/src/test/java/org/jabref/logic/search/SearchToSqlConversionTest.java +++ b/src/test/java/org/jabref/logic/search/SearchToSqlConversionTest.java @@ -9,7 +9,25 @@ class SearchToSqlConversionTest { @ParameterizedTest @CsvSource({ // Default search, query without any field name (case insensitive contains) - "SELECT entry_id FROM tableName WHERE (field_value ~* 'compute'), compute", + "SELECT entry_id FROM tableName WHERE (field_value ~* 'computer'), computer", + "SELECT entry_id FROM tableName WHERE (field_value ~* 'computer science'), \"computer science\"", // Phrase search + "SELECT entry_id FROM tableName WHERE (field_value ~* 'computer') OR (field_value ~* 'science'), computer science", // Should be searched as a phrase or as two separate words (OR)? + "SELECT entry_id FROM tableName WHERE (field_value ~* '!computer'), !computer", // Is the explanation should be escaped? + "SELECT entry_id FROM tableName WHERE (field_value ~* '!computer'), \"!computer\"", + // search in all fields case sensitive contains + "SELECT entry_id FROM tableName WHERE (field_value ~ 'computer'), any=!computer", + "SELECT entry_id FROM tableName WHERE (field_value ~ '!computer'), any=! !computer", // Is the explanation should be escaped? + // Regex search + "SELECT entry_id FROM tableName WHERE (field_value ~* 'Jabref.*Search'), Jabref.*Search", + "SELECT entry_id FROM tableName WHERE (field_value ~* 'Jabref.*Search'), \"Jabref.*Search\"", // This is wrong, this query should be a string literal searching for "Jabref.*Search" as string, should use syntax LIKE %...% + // And + "SELECT entry_id FROM tableName WHERE (field_value ~* 'computer') AND (field_value ~* 'science'), computer AND science", + // Or + "SELECT entry_id FROM tableName WHERE (field_value ~* 'computer') OR (field_value ~* 'science'), computer OR science", + // Grouping + "SELECT entry_id FROM tableName WHERE ((field_value ~* 'computer') AND (field_value ~* 'science')) OR (field_value ~* 'math'), (computer AND science) OR math", + "SELECT entry_id FROM tableName WHERE (field_value ~* 'computer') AND ((field_value ~* 'science') OR (field_value ~* 'math')), computer AND (science OR math)", + "SELECT entry_id FROM tableName WHERE ((field_value ~* 'computer') OR (field_value ~* 'science')) AND ((field_value ~* 'math') OR (field_value ~* 'physics')), (computer OR science) AND (math OR physics)", // case insensitive contains "SELECT entry_id FROM tableName WHERE (field_name = 'title' AND field_value ~* 'compute'), title=compute", // case sensitive contains