Add static library test
Change-Id: Id5212457a331811808c5ecfa24ca08498183fd48
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d52d56..684754c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,8 @@
include(GNUInstallDirs)
include_directories(/usr/local/include)
find_library(ROCKSDB librocksdb.so.5.11)
+find_library(ROCKSDB_STATIC librocksdb.a)
+
enable_testing()
add_library(collocatordb SHARED src/collocatordb.cc)
target_link_libraries(collocatordb pthread rt snappy z bz2 lz4 zstd ${ROCKSDB})
@@ -15,12 +17,16 @@
PUBLIC_HEADER src/collocatordb.h)
add_library(collocatordb_static STATIC src/collocatordb.cc)
-target_link_libraries(collocatordb_static pthread rt snappy bz2 lz4 zstd)
+target_link_libraries(collocatordb_static ${ROCKSDB_STATIC} pthread rt snappy z bz2 lz4 zstd)
add_executable(basic_test tests/basic_test.c tests/acutest.h)
TARGET_LINK_LIBRARIES(basic_test ${ROCKSDB} collocatordb)
add_test(BASIC_TEST basic_test)
+add_executable(static_library_test tests/basic_test.c tests/acutest.h)
+TARGET_LINK_LIBRARIES(static_library_test collocatordb_static)
+add_test(STATIC_LIBRARY_TEST static_library_test)
+
configure_file(collocatordb.pc.in collocatordb.pc @ONLY)
target_include_directories(collocatordb PRIVATE .)
install(TARGETS collocatordb collocatordb_static
diff --git a/tests/basic_test.c b/tests/basic_test.c
index d58dbe6..8872c48 100644
--- a/tests/basic_test.c
+++ b/tests/basic_test.c
@@ -49,8 +49,6 @@
char *needle = "\"word\":\"um\",\"f2\":264,\"f\":5,\"npmi\":-0.0556343,\"pmi\":-0.958064,\"llr\":2.87717,\"lfmd\":3.68579,\"md\":1.36386,\"dice\":0.00169952,\"ld\":4.79935,\"ln_count\":0,\"rn_count\":1,\"ln_pmi\":-1,\"rn_pmi\":-1,\"ldaf\":4.79935,\"win\":668,\"afwin\":668";
TEST_CHECK(strstr(json, needle) > 0);
TEST_MSG("Expected to contain: %s", needle);
- const COLLOCATOR *c = get_collocators(cdb, 62);
- printf("%s %lu\n", get_word(cdb,c[0].w2), c[0].f2);
}
void test_collocation_analysis() {
@@ -64,8 +62,6 @@
TEST_CHECK(strcmp(produced, expected) == 0);
TEST_MSG("Expected: %s", expected);
TEST_MSG("Produced: %s", produced);
- printf("%s\n", get_collocators_as_json(cdb,62));
-
}
int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) {
@@ -111,6 +107,7 @@
inc_collocator(cdb, 1, 2, 4); size++;
COLLOCATOR *c = get_collocators(cdb, 0);
TEST_ASSERT(c != NULL);
+ TEST_CHECK(c[0].w2 == 1);
TEST_CHECK(c[0].raw == 2001);
TEST_CHECK(c[0].left_raw == 200);
TEST_CHECK(c[0].right_raw == 200);