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

Go to the SVN repository for this file.

1 /* $Id: unit_test_dbtag.cpp 98604 2022-12-12 12:25:31Z gotvyans $
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: Eugene Vasilchenko, NCBI
27  *
28  * File Description:
29  * Unit test for CUser_object and CUser_field
30  *
31  * ===========================================================================
32  */
33 
34 #include <ncbi_pch.hpp>
35 
36 //#include <objects/general/general__.hpp>
37 
38 #include <corelib/ncbiapp.hpp>
39 #include <corelib/test_boost.hpp>
40 
41 #include <util/util_exception.hpp>
42 
44 
45 #include <common/test_assert.h> /* This header must go last */
46 
49 
50 BOOST_AUTO_TEST_CASE(s_TestDBTag1)
51 {
53  string str;
54  CDbtag::TDbtagGroup group;
55 
56  CDbtag dbtag1;
57  dbtag1.SetDb("AAA");
58  tag = dbtag1.GetType();
59  BOOST_CHECK_EQUAL(tag, CDbtag::eDbtagType_bad);
60 
61  CDbtag dbtag2;
62  dbtag2.SetDb("BioSample");
63  tag = dbtag2.GetType();
64  BOOST_CHECK_EQUAL(tag, CDbtag::eDbtagType_BioSample);
65 
66  CDbtag dbtag3;
67  dbtag3.SetDb("BioSamplE"); // wrong case
68  tag = dbtag3.GetType();
69  BOOST_CHECK_EQUAL(tag, CDbtag::eDbtagType_bad);
70 
71  BOOST_CHECK(!dbtag2.IsApproved());
72  BOOST_CHECK(dbtag2.IsApproved(CDbtag::eIsRefseq_Yes));
73  BOOST_CHECK(!dbtag3.IsApproved());
74  BOOST_CHECK(dbtag3.IsApprovedNoCase(CDbtag::eIsRefseq_Yes));
75 
76  group = dbtag2.GetDBFlags(str);
77  BOOST_CHECK_EQUAL(str, "BioSample");
78  BOOST_CHECK_EQUAL(group, CDbtag::fRefSeq);
79 
80  group = dbtag3.GetDBFlags(str);
81  BOOST_CHECK_EQUAL(str, "BioSample");
82  BOOST_CHECK_EQUAL(group, CDbtag::fRefSeq);
83 }
84 
85 BOOST_AUTO_TEST_CASE(s_TestDBTag2)
86 {
88  string str;
89  CDbtag::TDbtagGroup group;
90 
91  {
92  CDbtag dbtag;
93  dbtag.SetDb("Ensembl");
94  tag = dbtag.GetType();
95  BOOST_CHECK_EQUAL(tag, CDbtag::eDbtagType_Ensembl);
96  }
97 
98  {
99  CDbtag dbtag;
100  dbtag.SetDb("ENSEMBL");
101  tag = dbtag.GetType();
102  BOOST_CHECK_EQUAL(tag, CDbtag::eDbtagType_Ensembl);
103  }
104 
105  {
106  CDbtag dbtag;
107  dbtag.SetDb("EnsembL");
108  tag = dbtag.GetType();
109  BOOST_CHECK_EQUAL(tag, CDbtag::eDbtagType_bad);
110  BOOST_CHECK(!dbtag.IsApproved());
111  BOOST_CHECK(dbtag.IsApprovedNoCase());
112 
113  group = dbtag.GetDBFlags(str);
114  BOOST_CHECK_EQUAL(str, "Ensembl");
115  BOOST_CHECK_EQUAL(group, CDbtag::fGenBank);
116  }
117 
118  {
119  CDbtag dbtag;
120  dbtag.SetDb("ENSEMBL");
121  tag = dbtag.GetType();
122  BOOST_CHECK_EQUAL(tag, CDbtag::eDbtagType_Ensembl);
123  BOOST_CHECK(dbtag.IsApproved());
124  BOOST_CHECK(dbtag.IsApprovedNoCase());
125 
126  group = dbtag.GetDBFlags(str);
127  BOOST_CHECK_EQUAL(str, "ENSEMBL");
128  BOOST_CHECK_EQUAL(group, CDbtag::fGenBank);
129  }
130 
131  {
132  CDbtag dbtag;
133  dbtag.SetDb("ENSEMBL");
134  tag = dbtag.GetType();
135  BOOST_CHECK( dbtag.IsApproved(CDbtag::eIsRefseq_No));
139  }
140 }
Definition: Dbtag.hpp:53
EDbtagType GetType(void) const
Definition: Dbtag.cpp:289
@ eIsRefseq_No
Definition: Dbtag.hpp:261
@ eIsRefseq_Yes
Definition: Dbtag.hpp:262
@ eIsSource_Yes
Definition: Dbtag.hpp:266
@ fGenBank
Definition: Dbtag.hpp:232
@ fRefSeq
Definition: Dbtag.hpp:233
const char * IsApprovedNoCase(EIsRefseq refseq=eIsRefseq_No, EIsSource is_source=eIsSource_No) const
Definition: Dbtag.cpp:245
int TDbtagGroup
holds bitwise OR of "EDbtagGroup"
Definition: Dbtag.hpp:238
EDbtagType
Definition: Dbtag.hpp:58
@ eDbtagType_bad
Definition: Dbtag.hpp:59
@ eDbtagType_Ensembl
Definition: Dbtag.hpp:221
@ eDbtagType_BioSample
Definition: Dbtag.hpp:210
@ eIsEstOrGss_Yes
Definition: Dbtag.hpp:270
@ eIsEstOrGss_No
Definition: Dbtag.hpp:269
bool GetDBFlags(bool &is_refseq, bool &is_src, string &correct_caps) const
Definition: Dbtag.cpp:327
bool IsApproved(EIsRefseq refseq=eIsRefseq_No, EIsSource is_source=eIsSource_No, EIsEstOrGss is_est_or_gss=eIsEstOrGss_No) const
Definition: Dbtag.cpp:215
void SetDb(const TDb &value)
Assign a value to Db data member.
Definition: Dbtag_.hpp:229
const char * tag
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
static const char * str(char *buf, int n)
Definition: stats.c:84
Utility stuff for more convenient using of Boost.Test library.
USING_SCOPE(objects)
BOOST_AUTO_TEST_CASE(s_TestDBTag1)
USING_NCBI_SCOPE
Modified on Wed Nov 29 02:18:42 2023 by modify_doxy.py rev. 669887