]> git.donarmstrong.com Git - bamtools.git/blob - src/test/api/SamHeader/SamReadGroupDictionaryTest.h
Post-merge cleanup
[bamtools.git] / src / test / api / SamHeader / SamReadGroupDictionaryTest.h
1 #ifndef SAMREADGROUPDICTIONARY_TEST_H
2 #define SAMREADGROUPDICTIONARY_TEST_H
3
4 #include "api/SamReadGroupDictionary.h"
5 #include <gtest/gtest.h>
6 #include <vector>
7
8 TEST(SamReadGroupDictionaryTest, Empty) {
9     BamTools::SamReadGroupDictionary readGroups;
10     EXPECT_TRUE(readGroups.IsEmpty());
11     EXPECT_EQ(0, readGroups.Size());
12 }
13
14 TEST(SamReadGroupDictionaryTest, AddOne) {
15
16     BamTools::SamReadGroupDictionary readGroups;
17     readGroups.Add(BamTools::SamReadGroup());
18     EXPECT_FALSE(readGroups.IsEmpty());
19     EXPECT_EQ(1, readGroups.Size());
20 }
21
22 TEST(SamReadGroupDictionaryTest, AddMulti) {
23
24     std::vector<BamTools::SamReadGroup> groups;
25     groups.push_back(BamTools::SamReadGroup("1"));
26     groups.push_back(BamTools::SamReadGroup("2"));
27
28     BamTools::SamReadGroupDictionary readGroups;
29     readGroups.Add(groups);
30     EXPECT_FALSE(readGroups.IsEmpty());
31     EXPECT_EQ(2, readGroups.Size());
32 }
33
34 TEST(SamReadGroupDictionaryTest, AddDuplicate) {
35
36     std::vector<BamTools::SamReadGroup> groups;
37     groups.push_back(BamTools::SamReadGroup("1"));
38     groups.push_back(BamTools::SamReadGroup("1"));
39
40     // add duplicates through Add()
41     BamTools::SamReadGroupDictionary readGroups;
42     readGroups.Add(groups);
43     EXPECT_FALSE(readGroups.IsEmpty());
44     EXPECT_EQ(1, readGroups.Size());    // duplicate should not get added
45
46     // add duplicates through operator[]
47     readGroups.Clear();
48     readGroups["1"] = groups.at(0);
49     readGroups["1"] = groups.at(0);
50     EXPECT_FALSE(readGroups.IsEmpty());
51     EXPECT_EQ(1, readGroups.Size());     // duplicate should not get added
52 }
53
54 TEST(SamReadGroupDictionaryTest, Clear) {
55
56     // add a read group
57     BamTools::SamReadGroupDictionary readGroups;
58     readGroups.Add(BamTools::SamReadGroup());
59     EXPECT_FALSE(readGroups.IsEmpty());
60     EXPECT_EQ(1, readGroups.Size());;
61
62     // test clear
63     readGroups.Clear();
64     EXPECT_TRUE(readGroups.IsEmpty());
65     EXPECT_EQ(0, readGroups.Size());
66 }
67
68 #endif // SAMREADGROUPDICTIONARY_TEST_H