ModErn Text Analysis
META Enumerates Textual Applications
Classes | Functions
meta::testing Namespace Reference

Contains unit testing functions for the META toolkit. More...

Classes

struct  annotation_checker
 
struct  binary_checker
 
struct  file_guard
 Always makes sure a new file is created. More...
 
class  unit_test_exception
 Exception class used to report errors in the unit test. More...
 

Functions

template<class Analyzer >
void check_analyzer_expected (Analyzer &ana, corpus::document doc, uint64_t num_unique, uint64_t length)
 
int content_tokenize ()
 Test tokenization on documents with content. More...
 
int file_tokenize ()
 Test tokenization on documents that read content from files. More...
 
int analyzer_tests ()
 Runs the analyzer tests. More...
 
template<class Index , class Classifier >
void check_cv (Index &idx, Classifier &c, double min_accuracy)
 Checks that the CV accuracy is above a threshold. More...
 
template<class Index , class Classifier >
void check_split (Index &idx, Classifier &c, double min_accuracy)
 Checks that the split accuracy is above a threshold. More...
 
int run_tests (const std::string &type)
 Runs the classifier tests. More...
 
int classifier_tests ()
 Runs the classifier tests. More...
 
int compression_tests ()
 Tests compressed_file_reader and compressed_file_writer.
 
int filter_tests ()
 Tests filters. More...
 
void create_libsvm_config ()
 Creates a test-config.toml with the desired settings.
 
template<class Index >
void check_bcancer_expected (Index &idx)
 Asserts that the bcancer corpus was created correctly. More...
 
template<class Index >
void check_ceeaus_expected_fwd (Index &idx)
 Asserts that the bcancer corpus was created correctly. More...
 
template<class Index >
void check_bcancer_doc_id (Index &idx)
 Asserts that the ceeaus corpus was created correctly. More...
 
template<class Index >
void check_ceeaus_doc_id (Index &idx)
 Asserts that the ceeaus corpus was created correctly. More...
 
void ceeaus_forward_test ()
 Runs the ceeaus forward index tests.
 
void bcancer_forward_test ()
 Runs the bcancer forward index tests.
 
int forward_index_tests ()
 Runs all the forward_index tests. More...
 
int graph_tests ()
 Runs the undirected and directed graph tests. More...
 
void create_config (const std::string &corpus_type)
 Creates test-config.toml with the desired settings. More...
 
template<class Index >
void check_ceeaus_expected (Index &idx)
 Checks that ceeaus index was built correctly. More...
 
template<class Index >
void check_term_id (Index &idx)
 Checks that the term info is consistent with the correct one. More...
 
int inverted_index_tests ()
 Runs the inverted index tests. More...
 
int ir_eval_tests ()
 Runs the IR evaluation tests. More...
 
void label ()
 Tests libsvm strings containing a class label.
 
void no_label ()
 Tests libsvm strings not containing a class label.
 
void bad_label ()
 Tests libsvm strings containing a bad class label.
 
void bad_counts ()
 Tests libsvm strings containing a bad count data.
 
int libsvm_parser_tests ()
 Runs all the libsvm parser tests. More...
 
template<class Type >
void hard_func (Type &x)
 
template<class Type >
void easy_func (Type &x)
 
int test_speed (std::vector< double > &v)
 Assumes multi-core machine: tests speed; serial should be slower than parallel. More...
 
int test_correctness (std::vector< double > &v)
 Checks that each thread touches each index exactly once. More...
 
int test_threadpool ()
 Tests the threadpool. More...
 
int parallel_tests ()
 Tests all the parallel functions. More...
 
int parser_tests ()
 Tests for parser functionality. More...
 
template<class Ranker , class Index >
void test_rank (Ranker &r, Index &idx)
 Queries an index with its own docs to ensure that the query is the first doc returned. More...
 
int ranker_tests ()
 Runs all the ranking tests. More...
 
int stemmer_tests ()
 Runs all the stemming tests. More...
 
void assert_read (std::ifstream &file, const std::string &expect)
 
int string_list_tests ()
 Runs the string list tests. More...
 
std::string filename (const std::string &path)
 
template<class T , class K , class BinOp >
std::string assert_equal (const T &expected, const K &actual, const char *expstr, const char *actstr, BinOp &&binop)
 Allows the user to see what the evaluated statements are. More...
 
template<class T , class K >
std::string assert_equal (const T &expected, const K &actual, const char *expstr, const char *actstr)
 
template<class T , class K >
std::string assert_approx_equal (const T &expected, const K &actual, const char *expstr, const char *actstr)
 
template<class T , class K >
std::string assert_less (const T &expected, const K &actual, const char *expstr, const char *actstr)
 
template<class T , class K >
std::string assert_greater (const T &expected, const K &actual, const char *expstr, const char *actstr)
 
template<class Func >
int run_test (const std::string &test_name, Func &&func)
 Runs a unit test in a semi-controlled environment. More...
 
void write_file (uint16_t size=20)
 Writes a file to decode. More...
 
void assert_correctness (uint16_t size=20)
 Makes sure the content in the vocab map is correct. More...
 
void read_file (uint16_t size=20)
 Reads data from the vocab map file. More...
 
int vocabulary_map_tests ()
 Runs the vocab map tests. More...
 
template<class Graph >
void check_sizes (const Graph &g, uint64_t num_nodes, uint64_t num_edges)
 
int test_undirected ()
 
int test_directed ()
 
int test_betweenness ()
 
void missing_label ()
 
parser::parse_tree tree (std::string input)
 
void assert_tree_equal (std::string input, std::string expected, parser::tree_transformer &trns)
 
int transformer_tests ()
 
int head_finder_tests ()
 
int binarizer_tests ()
 
int debinarizer_tests ()
 
template<class Ranker , class Index >
void test_rank (Ranker &r, Index &idx, const std::string &encoding)
 

Detailed Description

Contains unit testing functions for the META toolkit.

Function Documentation

template<class Analyzer >
void meta::testing::check_analyzer_expected ( Analyzer &  ana,
corpus::document  doc,
uint64_t  num_unique,
uint64_t  length 
)
Parameters
anaThe anlyzer to use
docThe document to analyze
num_uniqueNumber of unique terms
lengthNumber of terms
int meta::testing::content_tokenize ( )

Test tokenization on documents with content.

Returns
the number of tests failed
int meta::testing::file_tokenize ( )

Test tokenization on documents that read content from files.

Returns
the number of tests failed
int meta::testing::analyzer_tests ( )

Runs the analyzer tests.

Returns
the number of tests failed
template<class Index , class Classifier >
void meta::testing::check_cv ( Index &  idx,
Classifier &  c,
double  min_accuracy 
)

Checks that the CV accuracy is above a threshold.

Parameters
idxThe index to run the classifier on
cThe classifier to test
min_accuracyThe mininum acceptable accuracy
template<class Index , class Classifier >
void meta::testing::check_split ( Index &  idx,
Classifier &  c,
double  min_accuracy 
)

Checks that the split accuracy is above a threshold.

Parameters
idxThe index to run the classifier on
cThe classifier to test
min_accuracyThe mininum acceptable accuracy
int meta::testing::run_tests ( const std::string &  type)

Runs the classifier tests.

Parameters
typeThe index type
Returns
the number of tests failed
int meta::testing::classifier_tests ( )

Runs the classifier tests.

Returns
the number of tests failed
int meta::testing::filter_tests ( )

Tests filters.

Returns
the number of tests failed
template<class Index >
void meta::testing::check_bcancer_expected ( Index &  idx)

Asserts that the bcancer corpus was created correctly.

Parameters
idxThe index to use
template<class Index >
void meta::testing::check_ceeaus_expected_fwd ( Index &  idx)

Asserts that the bcancer corpus was created correctly.

Parameters
idxThe index to use
template<class Index >
void meta::testing::check_bcancer_doc_id ( Index &  idx)

Asserts that the ceeaus corpus was created correctly.

Parameters
idxThe index to use
template<class Index >
void meta::testing::check_ceeaus_doc_id ( Index &  idx)

Asserts that the ceeaus corpus was created correctly.

Parameters
idxThe index to use
int meta::testing::forward_index_tests ( )

Runs all the forward_index tests.

Returns
the number of tests failed
int meta::testing::graph_tests ( )

Runs the undirected and directed graph tests.

Returns
the number of tests failed.
void meta::testing::create_config ( const std::string &  corpus_type)

Creates test-config.toml with the desired settings.

Parameters
corpus_typeline or file corpus
template<class Index >
void meta::testing::check_ceeaus_expected ( Index &  idx)

Checks that ceeaus index was built correctly.

Parameters
idxThe index to check
template<class Index >
void meta::testing::check_term_id ( Index &  idx)

Checks that the term info is consistent with the correct one.

Parameters
idxThe index to check
int meta::testing::inverted_index_tests ( )

Runs the inverted index tests.

Returns
the number of tests failed
int meta::testing::ir_eval_tests ( )

Runs the IR evaluation tests.

Returns
the number of tests failed
int meta::testing::libsvm_parser_tests ( )

Runs all the libsvm parser tests.

Returns
the number of tests failed
int meta::testing::test_speed ( std::vector< double > &  v)

Assumes multi-core machine: tests speed; serial should be slower than parallel.

Assumes multi-core machine...

Parameters
vA vector of doubles to perform math ops on
Returns
positive number if failed
int meta::testing::test_correctness ( std::vector< double > &  v)

Checks that each thread touches each index exactly once.

Parameters
vA vector of doubles to perform math ops on
Returns
positive number if failed
int meta::testing::test_threadpool ( )

Tests the threadpool.

Returns
the number of tests failed
int meta::testing::parallel_tests ( )

Tests all the parallel functions.

Returns
the number of tests failed
int meta::testing::parser_tests ( )

Tests for parser functionality.

Returns
the number of tests failed
template<class Ranker , class Index >
void meta::testing::test_rank ( Ranker &  r,
Index &  idx 
)

Queries an index with its own docs to ensure that the query is the first doc returned.

Parameters
rThe ranker to test
idxThe index to use
int meta::testing::ranker_tests ( )

Runs all the ranking tests.

Returns
the number of tests failed
int meta::testing::stemmer_tests ( )

Runs all the stemming tests.

Returns
the number of tests failed
void meta::testing::assert_read ( std::ifstream &  file,
const std::string &  expect 
)
Parameters
fileThe file to read from
expectWhat we expect to read
int meta::testing::string_list_tests ( )

Runs the string list tests.

Returns
the number of tests failed
std::string meta::testing::filename ( const std::string &  path)
inline
Parameters
pathThe path to truncate
template<class T , class K , class BinOp >
std::string meta::testing::assert_equal ( const T &  expected,
const K &  actual,
const char *  expstr,
const char *  actstr,
BinOp &&  binop 
)
inline

Allows the user to see what the evaluated statements are.

Parameters
expectedThe expected expression
actualThe actual expression
expstrThe expected string
actstrThe actual string
binopThe binary operator to compare the expressions; by default std::equal_to
template<class T , class K >
std::string meta::testing::assert_equal ( const T &  expected,
const K &  actual,
const char *  expstr,
const char *  actstr 
)
inline
Parameters
expectedThe expected expression
actualThe actual expression
expstrThe expected string
actstrThe actual string
template<class T , class K >
std::string meta::testing::assert_approx_equal ( const T &  expected,
const K &  actual,
const char *  expstr,
const char *  actstr 
)
inline
Parameters
expectedThe expected expression
actualThe actual expression
expstrThe expected string
actstrThe actual string
template<class T , class K >
std::string meta::testing::assert_less ( const T &  expected,
const K &  actual,
const char *  expstr,
const char *  actstr 
)
inline
Parameters
expectedThe expected expression
actualThe actual expression
expstrThe expected string
actstrThe actual string
template<class T , class K >
std::string meta::testing::assert_greater ( const T &  expected,
const K &  actual,
const char *  expstr,
const char *  actstr 
)
inline
Parameters
expectedThe expected expression
actualThe actual expression
expstrThe expected string
actstrThe actual string
template<class Func >
int meta::testing::run_test ( const std::string &  test_name,
Func &&  func 
)

Runs a unit test in a semi-controlled environment.

Parameters
testNameThe name to display when running this test
funcThe function (unit test) to run. This function should take no parameters and return void.
void meta::testing::write_file ( uint16_t  size = 20)

Writes a file to decode.

Parameters
sizeThe number of bytes in the file
void meta::testing::assert_correctness ( uint16_t  size = 20)

Makes sure the content in the vocab map is correct.

Parameters
sizeThe number of bytes in the file
void meta::testing::read_file ( uint16_t  size = 20)

Reads data from the vocab map file.

Parameters
sizeThe number of bytes in the file
int meta::testing::vocabulary_map_tests ( )

Runs the vocab map tests.

Returns
the number of tests failed