Skip to content

Commit

Permalink
Splitted up StorageValueColumnTest into multiple testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
klauck committed Oct 7, 2016
1 parent ee74cfc commit e0e5398
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/test/storage/value_column_test.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#include <string>
#include <vector>

#include "gtest/gtest.h"

#include "../../lib/storage/value_column.hpp"

TEST(StorageValueColumnTest, CreateColumn) {
// create column of different types
class StorageValueColumnTest : public ::testing::Test {
protected:
opossum::ValueColumn<int> vc_int;
EXPECT_EQ(vc_int.size(), 0u);

opossum::ValueColumn<std::string> vc_str;
EXPECT_EQ(vc_str.size(), 0u);

opossum::ValueColumn<double> vc_double;
};

TEST_F(StorageValueColumnTest, GetSize) {
EXPECT_EQ(vc_int.size(), 0u);
EXPECT_EQ(vc_str.size(), 0u);
EXPECT_EQ(vc_double.size(), 0u);
}

// add value of same type
TEST_F(StorageValueColumnTest, AddValueOfSameType) {
vc_int.append(3);
EXPECT_EQ(vc_int.size(), 1u);

Expand All @@ -24,17 +27,29 @@ TEST(StorageValueColumnTest, CreateColumn) {

vc_double.append(3.14);
EXPECT_EQ(vc_double.size(), 1u);
}

// add value of different type
TEST_F(StorageValueColumnTest, AddValueOfDifferentType) {
vc_int.append(3.14);
EXPECT_EQ(vc_int.size(), 2u);
EXPECT_EQ(vc_int.size(), 1u);
EXPECT_THROW(vc_int.append("Hi"), std::exception);

vc_str.append(3);
vc_str.append(4.44);
EXPECT_EQ(vc_str.size(), 3u);
EXPECT_EQ(vc_str.size(), 2u);

vc_double.append(4);
EXPECT_EQ(vc_double.size(), 2u);
EXPECT_EQ(vc_double.size(), 1u);
EXPECT_THROW(vc_double.append("Hi"), std::exception);
}

TEST_F(StorageValueColumnTest, RetrieveValue) {
vc_int.append(3);
EXPECT_EQ(vc_int.get_values()[0], 3);

vc_str.append("Hello");
EXPECT_EQ(vc_str.get_values()[0], "Hello");

vc_double.append(3.14);
EXPECT_EQ(vc_double.get_values()[0], 3.14);
}

0 comments on commit e0e5398

Please sign in to comment.