NCBI C++ ToolKit
local_taxon_unit_test.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: local_taxon_unit_test.cpp 98313 2022-10-27 09:55:11Z badrazat $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Azat Badretdin
27 *
28 * File Description:
29 * Sample unit tests file for testing SQLITE3 based taxonomy functionality
30 * ===========================================================================
31 */
32 
33 #include <ncbi_pch.hpp>
34 
35 #include <corelib/ncbi_system.hpp>
36 #include <corelib/ncbiapp.hpp>
37 
39 
40 #include <serial/serial.hpp>
41 #include <serial/objostr.hpp>
42 #include <serial/objistr.hpp>
43 
44 // This header must be included before all Boost.Test headers if there are any
45 #include <corelib/test_boost.hpp>
46 #include <algorithm>
47 
51 unique_ptr<CLocalTaxon> tax1;
52 
54 
56 {
57  // Your application initialization code here (optional)
58 }
59 
60 
62 {
63  CLocalTaxon::AddArguments(*arg_desc);
64 }
65 
66 
67 
69 {
70  // Your application finalization code here (optional)
71  // tax1.Fini();
72 }
73 
74 BOOST_AUTO_TEST_SUITE(local_taxon)
75 
77 {
78  // Here we can set some dependencies between tests (if one disabled or
79  // failed other shouldn't execute) and hard-coded disablings. Note though
80  // that more preferable way to make always disabled test is add to
81  // ini-file in UNITTESTS_DISABLE section this line:
82  // TestName = true
83 
84  NCBITEST_DEPENDS_ON(test_tax1_synonyms, test_local_taxon_init);
85 
86  // NCBITEST_DISABLE(AlwaysDisabled);
87 }
88 
89 BOOST_AUTO_TEST_CASE(test_local_taxon_init) {
91 }
92 
93 BOOST_AUTO_TEST_CASE(test_tax1_synonyms) {
94  auto synonyms = tax1->GetSynonyms(562);
95  list<string> expected_synonyms = {
96  "Bacillus coli",
97  "Bacterium coli",
98  "Bacterium coli commune",
99  "Enterococcus coli"
100  };
101 
102  BOOST_REQUIRE_MESSAGE( synonyms.size() == 4, "Number of synonyms returned is not 4" );
103  for(auto expected_synonym: expected_synonyms) {
104  BOOST_REQUIRE_MESSAGE( std::find(synonyms.begin(), synonyms.end(), expected_synonym) != synonyms.end(), expected_synonym + " not found in the output" );
105  }
106  for(auto synonym: synonyms) {
107  BOOST_REQUIRE_MESSAGE( std::find(expected_synonyms.begin(), expected_synonyms.end(), synonym) != expected_synonyms.end(), synonym + " is an extra synonym found in the output" );
108  }
109 }
110 
static void AddArguments(CArgDescriptions &arg_desc)
Definition: local_taxon.cpp:52
static CNcbiApplication * Instance(void)
Singleton method.
Definition: ncbiapp.cpp:244
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
@ eSerial_AsnBinary
ASN.1 binary.
Definition: serialdef.hpp:74
#define NCBITEST_DEPENDS_ON(test_name, dep_name)
Add dependency between test test_name and dep_name.
Definition: test_boost.hpp:925
USING_SCOPE(objects)
ESerialDataFormat format
NCBITEST_INIT_TREE()
NCBITEST_INIT_CMDLINE(arg_desc)
unique_ptr< CLocalTaxon > tax1
NCBITEST_AUTO_INIT()
BOOST_AUTO_TEST_CASE(test_local_taxon_init)
NCBITEST_AUTO_FINI()
BOOST_AUTO_TEST_SUITE_END()
Auxiliary class to convert a string into an argument count and vector.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Definition: ncbiapp_api.hpp:53
BOOST_AUTO_TEST_SUITE(psiblast_iteration)
Utility stuff for more convenient using of Boost.Test library.
Modified on Tue Feb 27 05:55:14 2024 by modify_doxy.py rev. 669887