Move tests to separate directory
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/572d3564 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/572d3564 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/572d3564 Branch: refs/heads/master Commit: 572d35647c881f0ba8a9b034f49240f0f7193c16 Parents: 2016986 Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Fri Jul 8 16:46:21 2016 +0200 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Fri Jul 8 16:46:21 2016 +0200 ---------------------------------------------------------------------- common/charmonizer.c | 15 +- common/charmonizer.main | 15 +- core/Lucy/Test.c | 161 --- core/Lucy/Test.cfh | 26 - core/Lucy/Test/Analysis/TestAnalyzer.c | 69 -- core/Lucy/Test/Analysis/TestAnalyzer.cfh | 39 - core/Lucy/Test/Analysis/TestCaseFolder.c | 73 -- core/Lucy/Test/Analysis/TestCaseFolder.cfh | 29 - core/Lucy/Test/Analysis/TestNormalizer.c | 188 ---- core/Lucy/Test/Analysis/TestNormalizer.cfh | 29 - core/Lucy/Test/Analysis/TestPolyAnalyzer.c | 179 ---- core/Lucy/Test/Analysis/TestPolyAnalyzer.cfh | 29 - core/Lucy/Test/Analysis/TestRegexTokenizer.c | 75 -- core/Lucy/Test/Analysis/TestRegexTokenizer.cfh | 29 - core/Lucy/Test/Analysis/TestSnowballStemmer.c | 116 --- core/Lucy/Test/Analysis/TestSnowballStemmer.cfh | 29 - .../Lucy/Test/Analysis/TestSnowballStopFilter.c | 86 -- .../Test/Analysis/TestSnowballStopFilter.cfh | 29 - core/Lucy/Test/Analysis/TestStandardTokenizer.c | 140 --- .../Test/Analysis/TestStandardTokenizer.cfh | 29 - core/Lucy/Test/Highlight/TestHeatMap.c | 175 ---- core/Lucy/Test/Highlight/TestHeatMap.cfh | 29 - core/Lucy/Test/Highlight/TestHighlighter.c | 446 --------- core/Lucy/Test/Highlight/TestHighlighter.cfh | 29 - core/Lucy/Test/Index/TestDocWriter.c | 37 - core/Lucy/Test/Index/TestDocWriter.cfh | 29 - core/Lucy/Test/Index/TestHighlightWriter.c | 37 - core/Lucy/Test/Index/TestHighlightWriter.cfh | 29 - core/Lucy/Test/Index/TestIndexManager.c | 63 -- core/Lucy/Test/Index/TestIndexManager.cfh | 28 - core/Lucy/Test/Index/TestPolyReader.c | 53 - core/Lucy/Test/Index/TestPolyReader.cfh | 28 - core/Lucy/Test/Index/TestPostingListWriter.c | 36 - core/Lucy/Test/Index/TestPostingListWriter.cfh | 29 - core/Lucy/Test/Index/TestSegWriter.c | 37 - core/Lucy/Test/Index/TestSegWriter.cfh | 29 - core/Lucy/Test/Index/TestSegment.c | 169 ---- core/Lucy/Test/Index/TestSegment.cfh | 29 - core/Lucy/Test/Index/TestSnapshot.c | 112 --- core/Lucy/Test/Index/TestSnapshot.cfh | 29 - core/Lucy/Test/Index/TestSortWriter.c | 323 ------ core/Lucy/Test/Index/TestSortWriter.cfh | 43 - core/Lucy/Test/Index/TestTermInfo.c | 68 -- core/Lucy/Test/Index/TestTermInfo.cfh | 29 - core/Lucy/Test/Object/TestBitVector.c | 453 --------- core/Lucy/Test/Object/TestBitVector.cfh | 29 - core/Lucy/Test/Object/TestI32Array.c | 73 -- core/Lucy/Test/Object/TestI32Array.cfh | 29 - core/Lucy/Test/Plan/TestArchitecture.c | 50 - core/Lucy/Test/Plan/TestArchitecture.cfh | 39 - core/Lucy/Test/Plan/TestBlobType.c | 59 -- core/Lucy/Test/Plan/TestBlobType.cfh | 29 - core/Lucy/Test/Plan/TestFieldMisc.c | 248 ----- core/Lucy/Test/Plan/TestFieldMisc.cfh | 29 - core/Lucy/Test/Plan/TestFieldType.c | 107 -- core/Lucy/Test/Plan/TestFieldType.cfh | 33 - core/Lucy/Test/Plan/TestFullTextType.c | 112 --- core/Lucy/Test/Plan/TestFullTextType.cfh | 29 - core/Lucy/Test/Plan/TestNumericType.c | 109 --- core/Lucy/Test/Plan/TestNumericType.cfh | 29 - core/Lucy/Test/Search/TestLeafQuery.c | 70 -- core/Lucy/Test/Search/TestLeafQuery.cfh | 29 - core/Lucy/Test/Search/TestMatchAllQuery.c | 57 -- core/Lucy/Test/Search/TestMatchAllQuery.cfh | 29 - core/Lucy/Test/Search/TestNOTQuery.c | 70 -- core/Lucy/Test/Search/TestNOTQuery.cfh | 29 - core/Lucy/Test/Search/TestNoMatchQuery.c | 57 -- core/Lucy/Test/Search/TestNoMatchQuery.cfh | 29 - core/Lucy/Test/Search/TestPhraseQuery.c | 53 - core/Lucy/Test/Search/TestPhraseQuery.cfh | 29 - core/Lucy/Test/Search/TestPolyQuery.c | 93 -- core/Lucy/Test/Search/TestPolyQuery.cfh | 39 - core/Lucy/Test/Search/TestQueryParser.c | 81 -- core/Lucy/Test/Search/TestQueryParser.cfh | 61 -- core/Lucy/Test/Search/TestQueryParserLogic.c | 976 ------------------- core/Lucy/Test/Search/TestQueryParserLogic.cfh | 32 - core/Lucy/Test/Search/TestQueryParserSyntax.c | 452 --------- core/Lucy/Test/Search/TestQueryParserSyntax.cfh | 32 - core/Lucy/Test/Search/TestRangeQuery.c | 75 -- core/Lucy/Test/Search/TestRangeQuery.cfh | 29 - core/Lucy/Test/Search/TestReqOptQuery.c | 73 -- core/Lucy/Test/Search/TestReqOptQuery.cfh | 29 - core/Lucy/Test/Search/TestSeriesMatcher.c | 136 --- core/Lucy/Test/Search/TestSeriesMatcher.cfh | 29 - core/Lucy/Test/Search/TestSortSpec.c | 642 ------------ core/Lucy/Test/Search/TestSortSpec.cfh | 43 - core/Lucy/Test/Search/TestSpan.c | 53 - core/Lucy/Test/Search/TestSpan.cfh | 29 - core/Lucy/Test/Search/TestTermQuery.c | 66 -- core/Lucy/Test/Search/TestTermQuery.cfh | 29 - core/Lucy/Test/Store/MockFileHandle.c | 66 -- core/Lucy/Test/Store/MockFileHandle.cfh | 44 - core/Lucy/Test/Store/TestCompoundFileReader.c | 375 ------- core/Lucy/Test/Store/TestCompoundFileReader.cfh | 29 - core/Lucy/Test/Store/TestCompoundFileWriter.c | 162 --- core/Lucy/Test/Store/TestCompoundFileWriter.cfh | 29 - core/Lucy/Test/Store/TestFSDirHandle.c | 106 -- core/Lucy/Test/Store/TestFSDirHandle.cfh | 29 - core/Lucy/Test/Store/TestFSFileHandle.c | 267 ----- core/Lucy/Test/Store/TestFSFileHandle.cfh | 29 - core/Lucy/Test/Store/TestFSFolder.c | 218 ----- core/Lucy/Test/Store/TestFSFolder.cfh | 29 - core/Lucy/Test/Store/TestFileHandle.c | 66 -- core/Lucy/Test/Store/TestFileHandle.cfh | 29 - core/Lucy/Test/Store/TestFolder.c | 540 ---------- core/Lucy/Test/Store/TestFolder.cfh | 29 - core/Lucy/Test/Store/TestFolderCommon.c | 562 ----------- core/Lucy/Test/Store/TestFolderCommon.cfh | 40 - core/Lucy/Test/Store/TestIOChunks.c | 126 --- core/Lucy/Test/Store/TestIOChunks.cfh | 31 - core/Lucy/Test/Store/TestIOPrimitives.c | 518 ---------- core/Lucy/Test/Store/TestIOPrimitives.cfh | 31 - core/Lucy/Test/Store/TestInStream.c | 225 ----- core/Lucy/Test/Store/TestInStream.cfh | 33 - core/Lucy/Test/Store/TestRAMDirHandle.c | 91 -- core/Lucy/Test/Store/TestRAMDirHandle.cfh | 29 - core/Lucy/Test/Store/TestRAMFileHandle.c | 177 ---- core/Lucy/Test/Store/TestRAMFileHandle.cfh | 29 - core/Lucy/Test/Store/TestRAMFolder.c | 521 ---------- core/Lucy/Test/Store/TestRAMFolder.cfh | 29 - core/Lucy/Test/TestSchema.c | 112 --- core/Lucy/Test/TestSchema.cfh | 48 - core/Lucy/Test/TestSimple.c | 112 --- core/Lucy/Test/TestSimple.cfh | 29 - core/Lucy/Test/TestUtils.c | 183 ---- core/Lucy/Test/TestUtils.cfh | 87 -- core/Lucy/Test/Util/TestFreezer.c | 178 ---- core/Lucy/Test/Util/TestFreezer.cfh | 29 - core/Lucy/Test/Util/TestIndexFileNames.c | 73 -- core/Lucy/Test/Util/TestIndexFileNames.cfh | 29 - core/Lucy/Test/Util/TestJson.c | 365 ------- core/Lucy/Test/Util/TestJson.cfh | 29 - core/Lucy/Test/Util/TestMemoryPool.c | 61 -- core/Lucy/Test/Util/TestMemoryPool.cfh | 29 - core/Lucy/Test/Util/TestNumberUtils.c | 473 --------- core/Lucy/Test/Util/TestNumberUtils.cfh | 29 - core/Lucy/Test/Util/TestPriorityQueue.c | 165 ---- core/Lucy/Test/Util/TestPriorityQueue.cfh | 39 - core/Lucy/Test/Util/TestSortExternal.c | 324 ------ core/Lucy/Test/Util/TestSortExternal.cfh | 29 - core/TestLucy.c | 22 - core/TestLucy.cfp | 8 - go/build.go | 1 + perl/Build.PL | 6 +- test/Lucy/Test.c | 161 +++ test/Lucy/Test.cfh | 26 + test/Lucy/Test/Analysis/TestAnalyzer.c | 69 ++ test/Lucy/Test/Analysis/TestAnalyzer.cfh | 39 + test/Lucy/Test/Analysis/TestCaseFolder.c | 73 ++ test/Lucy/Test/Analysis/TestCaseFolder.cfh | 29 + test/Lucy/Test/Analysis/TestNormalizer.c | 188 ++++ test/Lucy/Test/Analysis/TestNormalizer.cfh | 29 + test/Lucy/Test/Analysis/TestPolyAnalyzer.c | 179 ++++ test/Lucy/Test/Analysis/TestPolyAnalyzer.cfh | 29 + test/Lucy/Test/Analysis/TestRegexTokenizer.c | 75 ++ test/Lucy/Test/Analysis/TestRegexTokenizer.cfh | 29 + test/Lucy/Test/Analysis/TestSnowballStemmer.c | 116 +++ test/Lucy/Test/Analysis/TestSnowballStemmer.cfh | 29 + .../Lucy/Test/Analysis/TestSnowballStopFilter.c | 86 ++ .../Test/Analysis/TestSnowballStopFilter.cfh | 29 + test/Lucy/Test/Analysis/TestStandardTokenizer.c | 140 +++ .../Test/Analysis/TestStandardTokenizer.cfh | 29 + test/Lucy/Test/Highlight/TestHeatMap.c | 175 ++++ test/Lucy/Test/Highlight/TestHeatMap.cfh | 29 + test/Lucy/Test/Highlight/TestHighlighter.c | 446 +++++++++ test/Lucy/Test/Highlight/TestHighlighter.cfh | 29 + test/Lucy/Test/Index/TestDocWriter.c | 37 + test/Lucy/Test/Index/TestDocWriter.cfh | 29 + test/Lucy/Test/Index/TestHighlightWriter.c | 37 + test/Lucy/Test/Index/TestHighlightWriter.cfh | 29 + test/Lucy/Test/Index/TestIndexManager.c | 63 ++ test/Lucy/Test/Index/TestIndexManager.cfh | 28 + test/Lucy/Test/Index/TestPolyReader.c | 53 + test/Lucy/Test/Index/TestPolyReader.cfh | 28 + test/Lucy/Test/Index/TestPostingListWriter.c | 36 + test/Lucy/Test/Index/TestPostingListWriter.cfh | 29 + test/Lucy/Test/Index/TestSegWriter.c | 37 + test/Lucy/Test/Index/TestSegWriter.cfh | 29 + test/Lucy/Test/Index/TestSegment.c | 169 ++++ test/Lucy/Test/Index/TestSegment.cfh | 29 + test/Lucy/Test/Index/TestSnapshot.c | 112 +++ test/Lucy/Test/Index/TestSnapshot.cfh | 29 + test/Lucy/Test/Index/TestSortWriter.c | 323 ++++++ test/Lucy/Test/Index/TestSortWriter.cfh | 43 + test/Lucy/Test/Index/TestTermInfo.c | 68 ++ test/Lucy/Test/Index/TestTermInfo.cfh | 29 + test/Lucy/Test/Object/TestBitVector.c | 453 +++++++++ test/Lucy/Test/Object/TestBitVector.cfh | 29 + test/Lucy/Test/Object/TestI32Array.c | 73 ++ test/Lucy/Test/Object/TestI32Array.cfh | 29 + test/Lucy/Test/Plan/TestArchitecture.c | 50 + test/Lucy/Test/Plan/TestArchitecture.cfh | 39 + test/Lucy/Test/Plan/TestBlobType.c | 59 ++ test/Lucy/Test/Plan/TestBlobType.cfh | 29 + test/Lucy/Test/Plan/TestFieldMisc.c | 248 +++++ test/Lucy/Test/Plan/TestFieldMisc.cfh | 29 + test/Lucy/Test/Plan/TestFieldType.c | 107 ++ test/Lucy/Test/Plan/TestFieldType.cfh | 33 + test/Lucy/Test/Plan/TestFullTextType.c | 112 +++ test/Lucy/Test/Plan/TestFullTextType.cfh | 29 + test/Lucy/Test/Plan/TestNumericType.c | 109 +++ test/Lucy/Test/Plan/TestNumericType.cfh | 29 + test/Lucy/Test/Search/TestLeafQuery.c | 70 ++ test/Lucy/Test/Search/TestLeafQuery.cfh | 29 + test/Lucy/Test/Search/TestMatchAllQuery.c | 57 ++ test/Lucy/Test/Search/TestMatchAllQuery.cfh | 29 + test/Lucy/Test/Search/TestNOTQuery.c | 70 ++ test/Lucy/Test/Search/TestNOTQuery.cfh | 29 + test/Lucy/Test/Search/TestNoMatchQuery.c | 57 ++ test/Lucy/Test/Search/TestNoMatchQuery.cfh | 29 + test/Lucy/Test/Search/TestPhraseQuery.c | 53 + test/Lucy/Test/Search/TestPhraseQuery.cfh | 29 + test/Lucy/Test/Search/TestPolyQuery.c | 93 ++ test/Lucy/Test/Search/TestPolyQuery.cfh | 39 + test/Lucy/Test/Search/TestQueryParser.c | 81 ++ test/Lucy/Test/Search/TestQueryParser.cfh | 61 ++ test/Lucy/Test/Search/TestQueryParserLogic.c | 976 +++++++++++++++++++ test/Lucy/Test/Search/TestQueryParserLogic.cfh | 32 + test/Lucy/Test/Search/TestQueryParserSyntax.c | 452 +++++++++ test/Lucy/Test/Search/TestQueryParserSyntax.cfh | 32 + test/Lucy/Test/Search/TestRangeQuery.c | 75 ++ test/Lucy/Test/Search/TestRangeQuery.cfh | 29 + test/Lucy/Test/Search/TestReqOptQuery.c | 73 ++ test/Lucy/Test/Search/TestReqOptQuery.cfh | 29 + test/Lucy/Test/Search/TestSeriesMatcher.c | 136 +++ test/Lucy/Test/Search/TestSeriesMatcher.cfh | 29 + test/Lucy/Test/Search/TestSortSpec.c | 642 ++++++++++++ test/Lucy/Test/Search/TestSortSpec.cfh | 43 + test/Lucy/Test/Search/TestSpan.c | 53 + test/Lucy/Test/Search/TestSpan.cfh | 29 + test/Lucy/Test/Search/TestTermQuery.c | 66 ++ test/Lucy/Test/Search/TestTermQuery.cfh | 29 + test/Lucy/Test/Store/MockFileHandle.c | 66 ++ test/Lucy/Test/Store/MockFileHandle.cfh | 44 + test/Lucy/Test/Store/TestCompoundFileReader.c | 375 +++++++ test/Lucy/Test/Store/TestCompoundFileReader.cfh | 29 + test/Lucy/Test/Store/TestCompoundFileWriter.c | 162 +++ test/Lucy/Test/Store/TestCompoundFileWriter.cfh | 29 + test/Lucy/Test/Store/TestFSDirHandle.c | 106 ++ test/Lucy/Test/Store/TestFSDirHandle.cfh | 29 + test/Lucy/Test/Store/TestFSFileHandle.c | 267 +++++ test/Lucy/Test/Store/TestFSFileHandle.cfh | 29 + test/Lucy/Test/Store/TestFSFolder.c | 218 +++++ test/Lucy/Test/Store/TestFSFolder.cfh | 29 + test/Lucy/Test/Store/TestFileHandle.c | 66 ++ test/Lucy/Test/Store/TestFileHandle.cfh | 29 + test/Lucy/Test/Store/TestFolder.c | 540 ++++++++++ test/Lucy/Test/Store/TestFolder.cfh | 29 + test/Lucy/Test/Store/TestFolderCommon.c | 562 +++++++++++ test/Lucy/Test/Store/TestFolderCommon.cfh | 40 + test/Lucy/Test/Store/TestIOChunks.c | 126 +++ test/Lucy/Test/Store/TestIOChunks.cfh | 31 + test/Lucy/Test/Store/TestIOPrimitives.c | 518 ++++++++++ test/Lucy/Test/Store/TestIOPrimitives.cfh | 31 + test/Lucy/Test/Store/TestInStream.c | 225 +++++ test/Lucy/Test/Store/TestInStream.cfh | 33 + test/Lucy/Test/Store/TestRAMDirHandle.c | 91 ++ test/Lucy/Test/Store/TestRAMDirHandle.cfh | 29 + test/Lucy/Test/Store/TestRAMFileHandle.c | 177 ++++ test/Lucy/Test/Store/TestRAMFileHandle.cfh | 29 + test/Lucy/Test/Store/TestRAMFolder.c | 521 ++++++++++ test/Lucy/Test/Store/TestRAMFolder.cfh | 29 + test/Lucy/Test/TestSchema.c | 112 +++ test/Lucy/Test/TestSchema.cfh | 48 + test/Lucy/Test/TestSimple.c | 112 +++ test/Lucy/Test/TestSimple.cfh | 29 + test/Lucy/Test/TestUtils.c | 183 ++++ test/Lucy/Test/TestUtils.cfh | 87 ++ test/Lucy/Test/Util/TestFreezer.c | 178 ++++ test/Lucy/Test/Util/TestFreezer.cfh | 29 + test/Lucy/Test/Util/TestIndexFileNames.c | 73 ++ test/Lucy/Test/Util/TestIndexFileNames.cfh | 29 + test/Lucy/Test/Util/TestJson.c | 365 +++++++ test/Lucy/Test/Util/TestJson.cfh | 29 + test/Lucy/Test/Util/TestMemoryPool.c | 61 ++ test/Lucy/Test/Util/TestMemoryPool.cfh | 29 + test/Lucy/Test/Util/TestNumberUtils.c | 473 +++++++++ test/Lucy/Test/Util/TestNumberUtils.cfh | 29 + test/Lucy/Test/Util/TestPriorityQueue.c | 165 ++++ test/Lucy/Test/Util/TestPriorityQueue.cfh | 39 + test/Lucy/Test/Util/TestSortExternal.c | 324 ++++++ test/Lucy/Test/Util/TestSortExternal.cfh | 29 + test/TestLucy.c | 22 + test/TestLucy.cfp | 8 + 284 files changed, 15147 insertions(+), 15132 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/common/charmonizer.c b/common/charmonizer.c index 5393e6b..4c4bff0 100644 --- a/common/charmonizer.c +++ b/common/charmonizer.c @@ -8593,6 +8593,7 @@ typedef struct lucy_MakeFile { /* Directories. */ const char *base_dir; char *core_dir; + char *test_dir; const char *host_src_dir; char *autogen_src_dir; char *autogen_inc_dir; @@ -8781,6 +8782,7 @@ lucy_MakeFile_new(chaz_CLI *cli) { /* Initialize directories. */ self->base_dir = ".."; self->core_dir = chaz_Util_join(dir_sep, self->base_dir, "core", NULL); + self->test_dir = chaz_Util_join(dir_sep, self->base_dir, "test", NULL); if (chaz_CLI_defined(cli, "enable-perl")) { self->host_src_dir = "xs"; } @@ -8858,6 +8860,7 @@ lucy_MakeFile_destroy(lucy_MakeFile *self) { chaz_MakeFile_destroy(self->makefile); free(self->core_dir); + free(self->test_dir); free(self->autogen_inc_dir); free(self->autogen_src_dir); free(self->lemon_dir); @@ -8978,6 +8981,7 @@ lucy_MakeFile_write(lucy_MakeFile *self) { chaz_MakeBinary_add_src_dir(self->lib, self->host_src_dir); chaz_MakeBinary_add_src_dir(self->lib, self->core_dir); + chaz_MakeBinary_add_src_dir(self->lib, self->test_dir); chaz_MakeBinary_add_src_dir(self->lib, self->snowstem_dir); chaz_MakeBinary_add_src_dir(self->lib, self->snowstop_dir); chaz_MakeBinary_add_src_dir(self->lib, self->utf8proc_dir); @@ -9032,21 +9036,24 @@ lucy_MakeFile_write_c_cfc_rules(lucy_MakeFile *self) { sfc.var = chaz_MakeFile_add_var(self->makefile, "CLOWNFISH_HEADERS", NULL); chaz_Make_list_files(self->core_dir, "cfh", S_cfh_file_callback, &sfc); + chaz_Make_list_files(self->test_dir, "cfh", S_cfh_file_callback, &sfc); rule = chaz_MakeFile_add_rule(self->makefile, self->autogen_target, NULL); chaz_MakeRule_add_prereq(rule, "$(CLOWNFISH_HEADERS)"); if (cfish_prefix == NULL) { cfc_command = chaz_Util_join("", "cfc --source=", self->core_dir, + " --source=", self->test_dir, " --dest=autogen --header=cfc_header", NULL); } else { cfc_command = chaz_Util_join("", cfish_prefix, dir_sep, "bin", dir_sep, - "cfc --source=", self->core_dir, " --include=", - cfish_prefix, dir_sep, "share", dir_sep, - "clownfish", dir_sep, "include", - " --dest=autogen --header=cfc_header", NULL); + "cfc --source=", self->core_dir, " --source=", + self->test_dir, " --include=", cfish_prefix, + dir_sep, "share", dir_sep, "clownfish", dir_sep, + "include --dest=autogen --header=cfc_header", + NULL); } chaz_MakeRule_add_command(rule, cfc_command); http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/common/charmonizer.main b/common/charmonizer.main index 15a2061..e08fdfc 100644 --- a/common/charmonizer.main +++ b/common/charmonizer.main @@ -45,6 +45,7 @@ typedef struct lucy_MakeFile { /* Directories. */ const char *base_dir; char *core_dir; + char *test_dir; const char *host_src_dir; char *autogen_src_dir; char *autogen_inc_dir; @@ -233,6 +234,7 @@ lucy_MakeFile_new(chaz_CLI *cli) { /* Initialize directories. */ self->base_dir = ".."; self->core_dir = chaz_Util_join(dir_sep, self->base_dir, "core", NULL); + self->test_dir = chaz_Util_join(dir_sep, self->base_dir, "test", NULL); if (chaz_CLI_defined(cli, "enable-perl")) { self->host_src_dir = "xs"; } @@ -310,6 +312,7 @@ lucy_MakeFile_destroy(lucy_MakeFile *self) { chaz_MakeFile_destroy(self->makefile); free(self->core_dir); + free(self->test_dir); free(self->autogen_inc_dir); free(self->autogen_src_dir); free(self->lemon_dir); @@ -430,6 +433,7 @@ lucy_MakeFile_write(lucy_MakeFile *self) { chaz_MakeBinary_add_src_dir(self->lib, self->host_src_dir); chaz_MakeBinary_add_src_dir(self->lib, self->core_dir); + chaz_MakeBinary_add_src_dir(self->lib, self->test_dir); chaz_MakeBinary_add_src_dir(self->lib, self->snowstem_dir); chaz_MakeBinary_add_src_dir(self->lib, self->snowstop_dir); chaz_MakeBinary_add_src_dir(self->lib, self->utf8proc_dir); @@ -484,21 +488,24 @@ lucy_MakeFile_write_c_cfc_rules(lucy_MakeFile *self) { sfc.var = chaz_MakeFile_add_var(self->makefile, "CLOWNFISH_HEADERS", NULL); chaz_Make_list_files(self->core_dir, "cfh", S_cfh_file_callback, &sfc); + chaz_Make_list_files(self->test_dir, "cfh", S_cfh_file_callback, &sfc); rule = chaz_MakeFile_add_rule(self->makefile, self->autogen_target, NULL); chaz_MakeRule_add_prereq(rule, "$(CLOWNFISH_HEADERS)"); if (cfish_prefix == NULL) { cfc_command = chaz_Util_join("", "cfc --source=", self->core_dir, + " --source=", self->test_dir, " --dest=autogen --header=cfc_header", NULL); } else { cfc_command = chaz_Util_join("", cfish_prefix, dir_sep, "bin", dir_sep, - "cfc --source=", self->core_dir, " --include=", - cfish_prefix, dir_sep, "share", dir_sep, - "clownfish", dir_sep, "include", - " --dest=autogen --header=cfc_header", NULL); + "cfc --source=", self->core_dir, " --source=", + self->test_dir, " --include=", cfish_prefix, + dir_sep, "share", dir_sep, "clownfish", dir_sep, + "include --dest=autogen --header=cfc_header", + NULL); } chaz_MakeRule_add_command(rule, cfc_command); http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test.c b/core/Lucy/Test.c deleted file mode 100644 index 0edda50..0000000 --- a/core/Lucy/Test.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define CFISH_USE_SHORT_NAMES -#define TESTLUCY_USE_SHORT_NAMES - -#include "Lucy/Test.h" - -#include "Clownfish/TestHarness/TestBatch.h" -#include "Clownfish/TestHarness/TestSuite.h" - -#include "Lucy/Test/Analysis/TestAnalyzer.h" -#include "Lucy/Test/Analysis/TestCaseFolder.h" -#include "Lucy/Test/Analysis/TestNormalizer.h" -#include "Lucy/Test/Analysis/TestPolyAnalyzer.h" -#include "Lucy/Test/Analysis/TestRegexTokenizer.h" -#include "Lucy/Test/Analysis/TestSnowballStemmer.h" -#include "Lucy/Test/Analysis/TestSnowballStopFilter.h" -#include "Lucy/Test/Analysis/TestStandardTokenizer.h" -#include "Lucy/Test/Highlight/TestHeatMap.h" -#include "Lucy/Test/Highlight/TestHighlighter.h" -#include "Lucy/Test/Index/TestDocWriter.h" -#include "Lucy/Test/Index/TestHighlightWriter.h" -#include "Lucy/Test/Index/TestIndexManager.h" -#include "Lucy/Test/Index/TestPolyReader.h" -#include "Lucy/Test/Index/TestPostingListWriter.h" -#include "Lucy/Test/Index/TestSegWriter.h" -#include "Lucy/Test/Index/TestSegment.h" -#include "Lucy/Test/Index/TestSnapshot.h" -#include "Lucy/Test/Index/TestSortWriter.h" -#include "Lucy/Test/Index/TestTermInfo.h" -#include "Lucy/Test/Object/TestBitVector.h" -#include "Lucy/Test/Object/TestI32Array.h" -#include "Lucy/Test/Plan/TestBlobType.h" -#include "Lucy/Test/Plan/TestFieldMisc.h" -#include "Lucy/Test/Plan/TestFieldType.h" -#include "Lucy/Test/Plan/TestFullTextType.h" -#include "Lucy/Test/Plan/TestNumericType.h" -#include "Lucy/Test/Search/TestLeafQuery.h" -#include "Lucy/Test/Search/TestMatchAllQuery.h" -#include "Lucy/Test/Search/TestNOTQuery.h" -#include "Lucy/Test/Search/TestNoMatchQuery.h" -#include "Lucy/Test/Search/TestPhraseQuery.h" -#include "Lucy/Test/Search/TestPolyQuery.h" -#include "Lucy/Test/Search/TestQueryParserLogic.h" -#include "Lucy/Test/Search/TestQueryParserSyntax.h" -#include "Lucy/Test/Search/TestRangeQuery.h" -#include "Lucy/Test/Search/TestReqOptQuery.h" -#include "Lucy/Test/Search/TestSeriesMatcher.h" -#include "Lucy/Test/Search/TestSortSpec.h" -#include "Lucy/Test/Search/TestSpan.h" -#include "Lucy/Test/Search/TestTermQuery.h" -#include "Lucy/Test/Store/TestCompoundFileReader.h" -#include "Lucy/Test/Store/TestCompoundFileWriter.h" -#include "Lucy/Test/Store/TestFSDirHandle.h" -#include "Lucy/Test/Store/TestFSFileHandle.h" -#include "Lucy/Test/Store/TestFSFolder.h" -#include "Lucy/Test/Store/TestFileHandle.h" -#include "Lucy/Test/Store/TestFolder.h" -#include "Lucy/Test/Store/TestIOChunks.h" -#include "Lucy/Test/Store/TestIOPrimitives.h" -#include "Lucy/Test/Store/TestInStream.h" -#include "Lucy/Test/Store/TestRAMDirHandle.h" -#include "Lucy/Test/Store/TestRAMFileHandle.h" -#include "Lucy/Test/Store/TestRAMFolder.h" -#include "Lucy/Test/TestSchema.h" -#include "Lucy/Test/TestSimple.h" -#include "Lucy/Test/Util/TestFreezer.h" -#include "Lucy/Test/Util/TestIndexFileNames.h" -#include "Lucy/Test/Util/TestJson.h" -#include "Lucy/Test/Util/TestMemoryPool.h" -#include "Lucy/Test/Util/TestNumberUtils.h" -#include "Lucy/Test/Util/TestPriorityQueue.h" -#include "Lucy/Test/Util/TestSortExternal.h" - -TestSuite* -Test_create_test_suite() { - TestSuite *suite = TestSuite_new(); - - TestSuite_Add_Batch(suite, (TestBatch*)TestPriQ_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestBitVector_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSortExternal_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestMemPool_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestNumUtil_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestIxFileNames_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestJson_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFreezer_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestI32Arr_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestRAMFH_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFSFH_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestInStream_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFH_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestIOPrimitives_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestIOChunks_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestRAMDH_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFSDH_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFSFolder_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestRAMFolder_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFolder_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestIxManager_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestCFWriter_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestCFReader_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestAnalyzer_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestPolyAnalyzer_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestCaseFolder_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestRegexTokenizer_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSnowStop_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSnowStemmer_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestNormalizer_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestStandardTokenizer_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSnapshot_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestTermInfo_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFieldMisc_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestBatchSchema_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestDocWriter_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestHLWriter_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestPListWriter_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSegWriter_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSortWriter_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestPolyReader_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFullTextType_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestBlobType_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestNumericType_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestFType_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSeg_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestHighlighter_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSimple_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSpan_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestHeatMap_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestTermQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestPhraseQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSortSpec_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestRangeQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestANDQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestMatchAllQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestNOTQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestReqOptQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestLeafQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestNoMatchQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestSeriesMatcher_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestORQuery_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestQPLogic_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestQPSyntax_new()); - - return suite; -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test.cfh b/core/Lucy/Test.cfh deleted file mode 100644 index 3b39130..0000000 --- a/core/Lucy/Test.cfh +++ /dev/null @@ -1,26 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -/** Lucy test suite. - */ -inert class Lucy::Test { - inert incremented TestSuite* - create_test_suite(); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestAnalyzer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestAnalyzer.c b/core/Lucy/Test/Analysis/TestAnalyzer.c deleted file mode 100644 index 6df3223..0000000 --- a/core/Lucy/Test/Analysis/TestAnalyzer.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Analysis/TestAnalyzer.h" -#include "Lucy/Analysis/Analyzer.h" -#include "Lucy/Analysis/Inversion.h" - -TestAnalyzer* -TestAnalyzer_new() { - return (TestAnalyzer*)Class_Make_Obj(TESTANALYZER); -} - -DummyAnalyzer* -DummyAnalyzer_new() { - DummyAnalyzer *self = (DummyAnalyzer*)Class_Make_Obj(DUMMYANALYZER); - return DummyAnalyzer_init(self); -} - -DummyAnalyzer* -DummyAnalyzer_init(DummyAnalyzer *self) { - return (DummyAnalyzer*)Analyzer_init((Analyzer*)self); -} - -Inversion* -DummyAnalyzer_Transform_IMP(DummyAnalyzer *self, Inversion *inversion) { - UNUSED_VAR(self); - return (Inversion*)INCREF(inversion); -} - -static void -test_analysis(TestBatchRunner *runner) { - DummyAnalyzer *analyzer = DummyAnalyzer_new(); - String *source = Str_newf("foo bar baz"); - Vector *wanted = Vec_new(1); - Vec_Push(wanted, (Obj*)Str_newf("foo bar baz")); - TestUtils_test_analyzer(runner, (Analyzer*)analyzer, source, wanted, - "test basic analysis"); - DECREF(wanted); - DECREF(source); - DECREF(analyzer); -} - -void -TestAnalyzer_Run_IMP(TestAnalyzer *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 3); - test_analysis(runner); -} - - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestAnalyzer.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestAnalyzer.cfh b/core/Lucy/Test/Analysis/TestAnalyzer.cfh deleted file mode 100644 index 661e391..0000000 --- a/core/Lucy/Test/Analysis/TestAnalyzer.cfh +++ /dev/null @@ -1,39 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Analysis::TestAnalyzer - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestAnalyzer* - new(); - - void - Run(TestAnalyzer *self, TestBatchRunner *runner); -} - -class Lucy::Test::Analysis::DummyAnalyzer inherits Lucy::Analysis::Analyzer { - inert incremented DummyAnalyzer* - new(); - - inert DummyAnalyzer* - init(DummyAnalyzer *self); - - public incremented Inversion* - Transform(DummyAnalyzer *self, Inversion *inversion); -} - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestCaseFolder.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestCaseFolder.c b/core/Lucy/Test/Analysis/TestCaseFolder.c deleted file mode 100644 index 115362d..0000000 --- a/core/Lucy/Test/Analysis/TestCaseFolder.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTCASEFOLDER -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/Boolean.h" -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Analysis/TestCaseFolder.h" -#include "Lucy/Analysis/CaseFolder.h" - -TestCaseFolder* -TestCaseFolder_new() { - return (TestCaseFolder*)Class_Make_Obj(TESTCASEFOLDER); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - CaseFolder *case_folder = CaseFolder_new(); - CaseFolder *other = CaseFolder_new(); - Obj *dump = (Obj*)CaseFolder_Dump(case_folder); - CaseFolder *clone = (CaseFolder*)CaseFolder_Load(other, dump); - - TEST_TRUE(runner, CaseFolder_Equals(case_folder, (Obj*)other), "Equals"); - TEST_FALSE(runner, CaseFolder_Equals(case_folder, (Obj*)CFISH_TRUE), - "Not Equals"); - TEST_TRUE(runner, CaseFolder_Equals(case_folder, (Obj*)clone), - "Dump => Load round trip"); - - DECREF(case_folder); - DECREF(other); - DECREF(dump); - DECREF(clone); -} - -static void -test_analysis(TestBatchRunner *runner) { - CaseFolder *case_folder = CaseFolder_new(); - String *source = Str_newf("caPiTal ofFensE"); - Vector *wanted = Vec_new(1); - Vec_Push(wanted, (Obj*)Str_newf("capital offense")); - TestUtils_test_analyzer(runner, (Analyzer*)case_folder, source, wanted, - "lowercase plain text"); - DECREF(wanted); - DECREF(source); - DECREF(case_folder); -} - -void -TestCaseFolder_Run_IMP(TestCaseFolder *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 6); - test_Dump_Load_and_Equals(runner); - test_analysis(runner); -} - - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestCaseFolder.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestCaseFolder.cfh b/core/Lucy/Test/Analysis/TestCaseFolder.cfh deleted file mode 100644 index 6138139..0000000 --- a/core/Lucy/Test/Analysis/TestCaseFolder.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Analysis::TestCaseFolder - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestCaseFolder* - new(); - - void - Run(TestCaseFolder *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestNormalizer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestNormalizer.c b/core/Lucy/Test/Analysis/TestNormalizer.c deleted file mode 100644 index 6bb0fb7..0000000 --- a/core/Lucy/Test/Analysis/TestNormalizer.c +++ /dev/null @@ -1,188 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdlib.h> - -#define C_TESTLUCY_TESTNORMALIZER -#define C_LUCY_NORMALIZER -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/Boolean.h" -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Clownfish/TestHarness/TestUtils.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Analysis/TestNormalizer.h" -#include "Lucy/Analysis/Normalizer.h" -#include "Lucy/Store/FSFolder.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Util/Json.h" -#include "utf8proc.h" - -TestNormalizer* -TestNormalizer_new() { - return (TestNormalizer*)Class_Make_Obj(TESTNORMALIZER); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - Normalizer *normalizer[4]; - - String *NFC = SSTR_WRAP_C("NFC"); - String *NFKC = SSTR_WRAP_C("NFKC"); - - normalizer[0] = Normalizer_new(NFKC, true, false); - normalizer[1] = Normalizer_new(NFC, true, false); - normalizer[2] = Normalizer_new(NFKC, false, false); - normalizer[3] = Normalizer_new(NFKC, true, true); - - TEST_FALSE(runner, - Normalizer_Equals(normalizer[0], (Obj*)normalizer[1]), - "Equals() false with different normalization form"); - TEST_FALSE(runner, - Normalizer_Equals(normalizer[0], (Obj*)normalizer[2]), - "Equals() false with different case_fold flag"); - TEST_FALSE(runner, - Normalizer_Equals(normalizer[0], (Obj*)normalizer[3]), - "Equals() false with different strip_accents flag"); - - for (int i = 0; i < 4; ++i) { - Obj *dump = (Obj*)Normalizer_Dump(normalizer[i]); - Normalizer *clone = (Normalizer*)Normalizer_Load(normalizer[i], dump); - - TEST_TRUE(runner, - Normalizer_Equals(normalizer[i], (Obj*)clone), - "Dump => Load round trip"); - - DECREF(normalizer[i]); - DECREF(dump); - DECREF(clone); - } -} - -static void -test_normalization(TestBatchRunner *runner) { - FSFolder *modules_folder = TestUtils_modules_folder(); - if (modules_folder == NULL) { - SKIP(runner, 13, "Can't locate test data"); - return; - } - - String *path = Str_newf("unicode/utf8proc/tests.json"); - Vector *tests = (Vector*)Json_slurp_json((Folder*)modules_folder, path); - if (!tests) { RETHROW(Err_get_error()); } - - for (size_t i = 0, max = Vec_Get_Size(tests); i < max; i++) { - Hash *test = (Hash*)Vec_Fetch(tests, i); - String *form = (String*)Hash_Fetch_Utf8( - test, "normalization_form", 18); - bool case_fold = Bool_Get_Value((Boolean*)Hash_Fetch_Utf8( - test, "case_fold", 9)); - bool strip_accents = Bool_Get_Value((Boolean*)Hash_Fetch_Utf8( - test, "strip_accents", 13)); - Normalizer *normalizer = Normalizer_new(form, case_fold, strip_accents); - Vector *words = (Vector*)Hash_Fetch_Utf8(test, "words", 5); - Vector *norms = (Vector*)Hash_Fetch_Utf8(test, "norms", 5); - for (size_t j = 0, max = Vec_Get_Size(words); j < max; j++) { - String *word = (String*)Vec_Fetch(words, j); - Vector *got = Normalizer_Split(normalizer, word); - String *norm = (String*)Vec_Fetch(got, 0); - char *fstr = Str_To_Utf8(form); - char *wstr = Str_To_Utf8(word); - TEST_TRUE(runner, - norm - && Str_is_a(norm, STRING) - && Str_Equals(norm, Vec_Fetch(norms, j)), - "Normalize %s %d %d: %s", fstr, - case_fold, strip_accents, wstr - ); - free(fstr); - free(wstr); - DECREF(got); - } - DECREF(normalizer); - } - - DECREF(tests); - DECREF(modules_folder); - DECREF(path); -} - -static void -test_utf8proc_normalization(TestBatchRunner *runner) { - SKIP(runner, 1, - "utf8proc can't handle control chars or Unicode non-chars"); - return; - - for (int32_t i = 0; i < 100; i++) { - String *source = TestUtils_random_string(rand() % 40); - - // Normalize once. - uint8_t *normalized; - int32_t check = utf8proc_map((const uint8_t*)Str_Get_Ptr8(source), - (ssize_t)Str_Get_Size(source), - &normalized, - UTF8PROC_STABLE | - UTF8PROC_COMPOSE | - UTF8PROC_COMPAT | - UTF8PROC_CASEFOLD); - if (check < 0) { - lucy_Json_set_tolerant(1); - String *json = lucy_Json_to_json((Obj*)source); - if (!json) { - json = Str_newf("[failed to encode]"); - } - char *str = Str_To_Utf8(json); - FAIL(runner, "Failed to normalize: %s", str); - free(str); - DECREF(json); - DECREF(source); - return; - } - - // Normalize again. - size_t normalized_len = strlen((char*)normalized); - uint8_t *dupe; - int32_t dupe_check = utf8proc_map(normalized, (ssize_t)normalized_len, &dupe, - UTF8PROC_STABLE | - UTF8PROC_COMPOSE | - UTF8PROC_COMPAT | - UTF8PROC_CASEFOLD); - if (dupe_check < 0) { - THROW(ERR, "Unexpected normalization error: %i32", dupe_check); - } - int comparison = strcmp((char*)normalized, (char*)dupe); - free(dupe); - free(normalized); - DECREF(source); - if (comparison != 0) { - FAIL(runner, "Not fully normalized"); - return; - } - } - PASS(runner, "Normalization successful."); -} - -void -TestNormalizer_Run_IMP(TestNormalizer *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 21); - test_Dump_Load_and_Equals(runner); - test_normalization(runner); - test_utf8proc_normalization(runner); -} - - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestNormalizer.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestNormalizer.cfh b/core/Lucy/Test/Analysis/TestNormalizer.cfh deleted file mode 100644 index 0200838..0000000 --- a/core/Lucy/Test/Analysis/TestNormalizer.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Analysis::TestNormalizer - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestNormalizer* - new(); - - void - Run(TestNormalizer *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestPolyAnalyzer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestPolyAnalyzer.c b/core/Lucy/Test/Analysis/TestPolyAnalyzer.c deleted file mode 100644 index efb539c..0000000 --- a/core/Lucy/Test/Analysis/TestPolyAnalyzer.c +++ /dev/null @@ -1,179 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTPOLYANALYZER -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Analysis/TestPolyAnalyzer.h" -#include "Lucy/Analysis/PolyAnalyzer.h" -#include "Lucy/Analysis/Normalizer.h" -#include "Lucy/Analysis/RegexTokenizer.h" -#include "Lucy/Analysis/SnowballStopFilter.h" -#include "Lucy/Analysis/SnowballStemmer.h" -#include "Lucy/Analysis/StandardTokenizer.h" - -TestPolyAnalyzer* -TestPolyAnalyzer_new() { - return (TestPolyAnalyzer*)Class_Make_Obj(TESTPOLYANALYZER); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - if (!RegexTokenizer_is_available()) { - SKIP(runner, 3, "RegexTokenizer not available"); - return; - } - - String *EN = SSTR_WRAP_C("en"); - String *ES = SSTR_WRAP_C("es"); - PolyAnalyzer *analyzer = PolyAnalyzer_new(EN, NULL); - PolyAnalyzer *other = PolyAnalyzer_new(ES, NULL); - Obj *dump = (Obj*)PolyAnalyzer_Dump(analyzer); - Obj *other_dump = (Obj*)PolyAnalyzer_Dump(other); - PolyAnalyzer *clone = (PolyAnalyzer*)PolyAnalyzer_Load(other, dump); - PolyAnalyzer *other_clone - = (PolyAnalyzer*)PolyAnalyzer_Load(other, other_dump); - - TEST_FALSE(runner, PolyAnalyzer_Equals(analyzer, (Obj*)other), - "Equals() false with different language"); - TEST_TRUE(runner, PolyAnalyzer_Equals(analyzer, (Obj*)clone), - "Dump => Load round trip"); - TEST_TRUE(runner, PolyAnalyzer_Equals(other, (Obj*)other_clone), - "Dump => Load round trip"); - - DECREF(analyzer); - DECREF(dump); - DECREF(clone); - DECREF(other); - DECREF(other_dump); - DECREF(other_clone); -} - -static void -test_analysis(TestBatchRunner *runner) { - String *EN = SSTR_WRAP_C("en"); - String *source_text = Str_newf("Eats, shoots and leaves."); - Normalizer *normalizer = Normalizer_new(NULL, true, false); - StandardTokenizer *tokenizer = StandardTokenizer_new(); - SnowballStopFilter *stopfilter = SnowStop_new(EN, NULL); - SnowballStemmer *stemmer = SnowStemmer_new(EN); - - { - Vector *analyzers = Vec_new(0); - PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers); - Vector *expected = Vec_new(1); - Vec_Push(expected, INCREF(source_text)); - TestUtils_test_analyzer(runner, (Analyzer*)polyanalyzer, source_text, - expected, "No sub analyzers"); - DECREF(expected); - DECREF(polyanalyzer); - DECREF(analyzers); - } - - { - Vector *analyzers = Vec_new(0); - Vec_Push(analyzers, INCREF(normalizer)); - PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers); - Vector *expected = Vec_new(1); - Vec_Push(expected, (Obj*)Str_newf("eats, shoots and leaves.")); - TestUtils_test_analyzer(runner, (Analyzer*)polyanalyzer, source_text, - expected, "With Normalizer"); - DECREF(expected); - DECREF(polyanalyzer); - DECREF(analyzers); - } - - { - Vector *analyzers = Vec_new(0); - Vec_Push(analyzers, INCREF(normalizer)); - Vec_Push(analyzers, INCREF(tokenizer)); - PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers); - Vector *expected = Vec_new(1); - Vec_Push(expected, (Obj*)Str_newf("eats")); - Vec_Push(expected, (Obj*)Str_newf("shoots")); - Vec_Push(expected, (Obj*)Str_newf("and")); - Vec_Push(expected, (Obj*)Str_newf("leaves")); - TestUtils_test_analyzer(runner, (Analyzer*)polyanalyzer, source_text, - expected, "With StandardTokenizer"); - DECREF(expected); - DECREF(polyanalyzer); - DECREF(analyzers); - } - - { - Vector *analyzers = Vec_new(0); - Vec_Push(analyzers, INCREF(normalizer)); - Vec_Push(analyzers, INCREF(tokenizer)); - Vec_Push(analyzers, INCREF(stopfilter)); - PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers); - Vector *expected = Vec_new(1); - Vec_Push(expected, (Obj*)Str_newf("eats")); - Vec_Push(expected, (Obj*)Str_newf("shoots")); - Vec_Push(expected, (Obj*)Str_newf("leaves")); - TestUtils_test_analyzer(runner, (Analyzer*)polyanalyzer, source_text, - expected, "With SnowballStopFilter"); - DECREF(expected); - DECREF(polyanalyzer); - DECREF(analyzers); - } - - { - Vector *analyzers = Vec_new(0); - Vec_Push(analyzers, INCREF(normalizer)); - Vec_Push(analyzers, INCREF(tokenizer)); - Vec_Push(analyzers, INCREF(stopfilter)); - Vec_Push(analyzers, INCREF(stemmer)); - PolyAnalyzer *polyanalyzer = PolyAnalyzer_new(NULL, analyzers); - Vector *expected = Vec_new(1); - Vec_Push(expected, (Obj*)Str_newf("eat")); - Vec_Push(expected, (Obj*)Str_newf("shoot")); - Vec_Push(expected, (Obj*)Str_newf("leav")); - TestUtils_test_analyzer(runner, (Analyzer*)polyanalyzer, source_text, - expected, "With SnowballStemmer"); - DECREF(expected); - DECREF(polyanalyzer); - DECREF(analyzers); - } - - DECREF(stemmer); - DECREF(stopfilter); - DECREF(tokenizer); - DECREF(normalizer); - DECREF(source_text); -} - -static void -test_Get_Analyzers(TestBatchRunner *runner) { - Vector *analyzers = Vec_new(0); - PolyAnalyzer *analyzer = PolyAnalyzer_new(NULL, analyzers); - TEST_TRUE(runner, PolyAnalyzer_Get_Analyzers(analyzer) == analyzers, - "Get_Analyzers()"); - DECREF(analyzer); - DECREF(analyzers); -} - -void -TestPolyAnalyzer_Run_IMP(TestPolyAnalyzer *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 19); - test_Dump_Load_and_Equals(runner); - test_analysis(runner); - test_Get_Analyzers(runner); -} - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestPolyAnalyzer.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestPolyAnalyzer.cfh b/core/Lucy/Test/Analysis/TestPolyAnalyzer.cfh deleted file mode 100644 index cd50a76..0000000 --- a/core/Lucy/Test/Analysis/TestPolyAnalyzer.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Analysis::TestPolyAnalyzer - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestPolyAnalyzer* - new(); - - void - Run(TestPolyAnalyzer *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestRegexTokenizer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestRegexTokenizer.c b/core/Lucy/Test/Analysis/TestRegexTokenizer.c deleted file mode 100644 index d24ea1d..0000000 --- a/core/Lucy/Test/Analysis/TestRegexTokenizer.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTREGEXTOKENIZER -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Analysis/TestRegexTokenizer.h" -#include "Lucy/Analysis/RegexTokenizer.h" - - -TestRegexTokenizer* -TestRegexTokenizer_new() { - return (TestRegexTokenizer*)Class_Make_Obj(TESTREGEXTOKENIZER); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - if (!RegexTokenizer_is_available()) { - SKIP(runner, 3, "RegexTokenizer not available"); - return; - } - - RegexTokenizer *word_char_tokenizer - = RegexTokenizer_new(SSTR_WRAP_C("\\w+")); - RegexTokenizer *whitespace_tokenizer - = RegexTokenizer_new(SSTR_WRAP_C("\\S+")); - Obj *word_char_dump = RegexTokenizer_Dump(word_char_tokenizer); - Obj *whitespace_dump = RegexTokenizer_Dump(whitespace_tokenizer); - RegexTokenizer *word_char_clone - = RegexTokenizer_Load(whitespace_tokenizer, word_char_dump); - RegexTokenizer *whitespace_clone - = RegexTokenizer_Load(whitespace_tokenizer, whitespace_dump); - - TEST_FALSE(runner, - RegexTokenizer_Equals(word_char_tokenizer, (Obj*)whitespace_tokenizer), - "Equals() false with different pattern"); - TEST_TRUE(runner, - RegexTokenizer_Equals(word_char_tokenizer, (Obj*)word_char_clone), - "Dump => Load round trip"); - TEST_TRUE(runner, - RegexTokenizer_Equals(whitespace_tokenizer, (Obj*)whitespace_clone), - "Dump => Load round trip"); - - DECREF(word_char_tokenizer); - DECREF(word_char_dump); - DECREF(word_char_clone); - DECREF(whitespace_tokenizer); - DECREF(whitespace_dump); - DECREF(whitespace_clone); -} - -void -TestRegexTokenizer_Run_IMP(TestRegexTokenizer *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 3); - test_Dump_Load_and_Equals(runner); -} - - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestRegexTokenizer.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestRegexTokenizer.cfh b/core/Lucy/Test/Analysis/TestRegexTokenizer.cfh deleted file mode 100644 index 00e3a60..0000000 --- a/core/Lucy/Test/Analysis/TestRegexTokenizer.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Analysis::TestRegexTokenizer - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestRegexTokenizer* - new(); - - void - Run(TestRegexTokenizer *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestSnowballStemmer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestSnowballStemmer.c b/core/Lucy/Test/Analysis/TestSnowballStemmer.c deleted file mode 100644 index 4da377f..0000000 --- a/core/Lucy/Test/Analysis/TestSnowballStemmer.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTSNOWBALLSTEMMER -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/HashIterator.h" -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Analysis/TestSnowballStemmer.h" -#include "Lucy/Analysis/SnowballStemmer.h" -#include "Lucy/Store/FSFolder.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Util/Json.h" - -TestSnowballStemmer* -TestSnowStemmer_new() { - return (TestSnowballStemmer*)Class_Make_Obj(TESTSNOWBALLSTEMMER); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - String *EN = SSTR_WRAP_C("en"); - String *ES = SSTR_WRAP_C("es"); - SnowballStemmer *stemmer = SnowStemmer_new(EN); - SnowballStemmer *other = SnowStemmer_new(ES); - Obj *dump = (Obj*)SnowStemmer_Dump(stemmer); - Obj *other_dump = (Obj*)SnowStemmer_Dump(other); - SnowballStemmer *clone = (SnowballStemmer*)SnowStemmer_Load(other, dump); - SnowballStemmer *other_clone = (SnowballStemmer*)SnowStemmer_Load(other, other_dump); - - TEST_FALSE(runner, - SnowStemmer_Equals(stemmer, (Obj*)other), - "Equals() false with different language"); - TEST_TRUE(runner, - SnowStemmer_Equals(stemmer, (Obj*)clone), - "Dump => Load round trip"); - TEST_TRUE(runner, - SnowStemmer_Equals(other, (Obj*)other_clone), - "Dump => Load round trip"); - - DECREF(stemmer); - DECREF(dump); - DECREF(clone); - DECREF(other); - DECREF(other_dump); - DECREF(other_clone); -} - -static void -test_stemming(TestBatchRunner *runner) { - FSFolder *modules_folder = TestUtils_modules_folder(); - if (modules_folder == NULL) { - SKIP(runner, 150, "Can't locate test data"); - return; - } - - String *path = Str_newf("analysis/snowstem/source/test/tests.json"); - Hash *tests = (Hash*)Json_slurp_json((Folder*)modules_folder, path); - if (!tests) { RETHROW(Err_get_error()); } - - HashIterator *iter = HashIter_new(tests); - while (HashIter_Next(iter)) { - String *iso = HashIter_Get_Key(iter); - char *iso_str = Str_To_Utf8(iso); - Hash *lang_data = (Hash*)HashIter_Get_Value(iter); - Vector *words = (Vector*)Hash_Fetch_Utf8(lang_data, "words", 5); - Vector *stems = (Vector*)Hash_Fetch_Utf8(lang_data, "stems", 5); - SnowballStemmer *stemmer = SnowStemmer_new(iso); - for (size_t i = 0, max = Vec_Get_Size(words); i < max; i++) { - String *word = (String*)Vec_Fetch(words, i); - char *wstr = Str_To_Utf8(word); - Vector *got = SnowStemmer_Split(stemmer, word); - String *stem = (String*)Vec_Fetch(got, 0); - TEST_TRUE(runner, - stem - && Str_is_a(stem, STRING) - && Str_Equals(stem, Vec_Fetch(stems, i)), - "Stem %s: %s", iso_str, wstr - ); - free(wstr); - DECREF(got); - } - free(iso_str); - DECREF(stemmer); - } - DECREF(iter); - - DECREF(tests); - DECREF(modules_folder); - DECREF(path); -} - -void -TestSnowStemmer_Run_IMP(TestSnowballStemmer *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 153); - test_Dump_Load_and_Equals(runner); - test_stemming(runner); -} - - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestSnowballStemmer.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestSnowballStemmer.cfh b/core/Lucy/Test/Analysis/TestSnowballStemmer.cfh deleted file mode 100644 index 7c37248..0000000 --- a/core/Lucy/Test/Analysis/TestSnowballStemmer.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Analysis::TestSnowballStemmer nickname TestSnowStemmer - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestSnowballStemmer* - new(); - - void - Run(TestSnowballStemmer *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestSnowballStopFilter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestSnowballStopFilter.c b/core/Lucy/Test/Analysis/TestSnowballStopFilter.c deleted file mode 100644 index dc555f1..0000000 --- a/core/Lucy/Test/Analysis/TestSnowballStopFilter.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTSNOWBALLSTOPFILTER -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Analysis/TestSnowballStopFilter.h" -#include "Lucy/Analysis/SnowballStopFilter.h" - -TestSnowballStopFilter* -TestSnowStop_new() { - return (TestSnowballStopFilter*)Class_Make_Obj(TESTSNOWBALLSTOPFILTER); -} - -static SnowballStopFilter* -S_make_stopfilter(void *unused, ...) { - va_list args; - SnowballStopFilter *self = (SnowballStopFilter*)Class_Make_Obj(SNOWBALLSTOPFILTER); - Hash *stoplist = Hash_new(0); - char *stopword; - - va_start(args, unused); - while (NULL != (stopword = va_arg(args, char*))) { - Hash_Store_Utf8(stoplist, stopword, strlen(stopword), - (Obj*)Str_newf("")); - } - va_end(args); - - self = SnowStop_init(self, NULL, stoplist); - DECREF(stoplist); - return self; -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - SnowballStopFilter *stopfilter = - S_make_stopfilter(NULL, "foo", "bar", "baz", NULL); - SnowballStopFilter *other = - S_make_stopfilter(NULL, "foo", "bar", NULL); - Obj *dump = SnowStop_Dump(stopfilter); - Obj *other_dump = SnowStop_Dump(other); - SnowballStopFilter *clone = (SnowballStopFilter*)SnowStop_Load(other, dump); - SnowballStopFilter *other_clone = (SnowballStopFilter*)SnowStop_Load(other, other_dump); - - TEST_FALSE(runner, - SnowStop_Equals(stopfilter, (Obj*)other), - "Equals() false with different stoplist"); - TEST_TRUE(runner, - SnowStop_Equals(stopfilter, (Obj*)clone), - "Dump => Load round trip"); - TEST_TRUE(runner, - SnowStop_Equals(other, (Obj*)other_clone), - "Dump => Load round trip"); - - DECREF(stopfilter); - DECREF(dump); - DECREF(clone); - DECREF(other); - DECREF(other_dump); - DECREF(other_clone); -} - -void -TestSnowStop_Run_IMP(TestSnowballStopFilter *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 3); - test_Dump_Load_and_Equals(runner); -} - - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestSnowballStopFilter.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestSnowballStopFilter.cfh b/core/Lucy/Test/Analysis/TestSnowballStopFilter.cfh deleted file mode 100644 index c916694..0000000 --- a/core/Lucy/Test/Analysis/TestSnowballStopFilter.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Analysis::TestSnowballStopFilter nickname TestSnowStop - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestSnowballStopFilter* - new(); - - void - Run(TestSnowballStopFilter *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestStandardTokenizer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestStandardTokenizer.c b/core/Lucy/Test/Analysis/TestStandardTokenizer.c deleted file mode 100644 index 548bf2f..0000000 --- a/core/Lucy/Test/Analysis/TestStandardTokenizer.c +++ /dev/null @@ -1,140 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTSTANDARDTOKENIZER -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Analysis/TestStandardTokenizer.h" -#include "Lucy/Analysis/StandardTokenizer.h" -#include "Lucy/Store/FSFolder.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Util/Json.h" - -TestStandardTokenizer* -TestStandardTokenizer_new() { - return (TestStandardTokenizer*)Class_Make_Obj(TESTSTANDARDTOKENIZER); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - StandardTokenizer *tokenizer = StandardTokenizer_new(); - Obj *dump = StandardTokenizer_Dump(tokenizer); - StandardTokenizer *clone - = (StandardTokenizer*)StandardTokenizer_Load(tokenizer, dump); - - TEST_TRUE(runner, - StandardTokenizer_Equals(tokenizer, (Obj*)clone), - "Dump => Load round trip"); - - DECREF(tokenizer); - DECREF(dump); - DECREF(clone); -} - -static void -test_tokenizer(TestBatchRunner *runner) { - StandardTokenizer *tokenizer = StandardTokenizer_new(); - - String *word = SSTR_WRAP_C( - " ." - "tha\xCC\x82t's" - ":" - "1,02\xC2\xADZ4.38" - "\xE0\xB8\x81\xC2\xAD\xC2\xAD" - "\xF0\xA0\x80\x80" - "a" - "/"); - Vector *got = StandardTokenizer_Split(tokenizer, word); - String *token = (String*)Vec_Fetch(got, 0); - char *token_str = Str_To_Utf8(token); - TEST_TRUE(runner, - token - && Str_is_a(token, STRING) - && Str_Equals_Utf8(token, "tha\xcc\x82t's", 8), - "Token: %s", token_str); - free(token_str); - token = (String*)Vec_Fetch(got, 1); - token_str = Str_To_Utf8(token); - TEST_TRUE(runner, - token - && Str_is_a(token, STRING) - && Str_Equals_Utf8(token, "1,02\xC2\xADZ4.38", 11), - "Token: %s", token_str); - free(token_str); - token = (String*)Vec_Fetch(got, 2); - token_str = Str_To_Utf8(token); - TEST_TRUE(runner, - token - && Str_is_a(token, STRING) - && Str_Equals_Utf8(token, "\xE0\xB8\x81\xC2\xAD\xC2\xAD", 7), - "Token: %s", token_str); - free(token_str); - token = (String*)Vec_Fetch(got, 3); - token_str = Str_To_Utf8(token); - TEST_TRUE(runner, - token - && Str_is_a(token, STRING) - && Str_Equals_Utf8(token, "\xF0\xA0\x80\x80", 4), - "Token: %s", token_str); - free(token_str); - token = (String*)Vec_Fetch(got, 4); - token_str = Str_To_Utf8(token); - TEST_TRUE(runner, - token - && Str_is_a(token, STRING) - && Str_Equals_Utf8(token, "a", 1), - "Token: %s", token_str); - free(token_str); - DECREF(got); - - FSFolder *modules_folder = TestUtils_modules_folder(); - if (modules_folder == NULL) { - SKIP(runner, 1372, "Can't locate test data"); - } - else { - String *path = Str_newf("unicode/ucd/WordBreakTest.json"); - Vector *tests = (Vector*)Json_slurp_json((Folder*)modules_folder, path); - if (!tests) { RETHROW(Err_get_error()); } - - for (size_t i = 0, max = Vec_Get_Size(tests); i < max; i++) { - Hash *test = (Hash*)Vec_Fetch(tests, i); - String *text = (String*)Hash_Fetch_Utf8(test, "text", 4); - Vector *wanted = (Vector*)Hash_Fetch_Utf8(test, "words", 5); - Vector *got = StandardTokenizer_Split(tokenizer, text); - TEST_TRUE(runner, Vec_Equals(wanted, (Obj*)got), "UCD test #%d", - (int)i + 1); - DECREF(got); - } - - DECREF(tests); - DECREF(modules_folder); - DECREF(path); - } - - DECREF(tokenizer); -} - -void -TestStandardTokenizer_Run_IMP(TestStandardTokenizer *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 1378); - test_Dump_Load_and_Equals(runner); - test_tokenizer(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Analysis/TestStandardTokenizer.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestStandardTokenizer.cfh b/core/Lucy/Test/Analysis/TestStandardTokenizer.cfh deleted file mode 100644 index 8e3d942..0000000 --- a/core/Lucy/Test/Analysis/TestStandardTokenizer.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Analysis::TestStandardTokenizer - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestStandardTokenizer* - new(); - - void - Run(TestStandardTokenizer *self, TestBatchRunner *runner); -} - -