1 // Copyright (c) 2016 The WebM project authors. All Rights Reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
8 #include "webm/element.h"
9
10 #include <string>
11 #include <utility>
12
13 #include "gtest/gtest.h"
14
15 using webm::Element;
16
17 namespace {
18
19 class ElementTest : public testing::Test {};
20
TEST_F(ElementTest,Construction)21 TEST_F(ElementTest, Construction) {
22 Element<int> value_initialized;
23 EXPECT_EQ(false, value_initialized.is_present());
24 EXPECT_EQ(0, value_initialized.value());
25
26 Element<int> absent_custom_default(1);
27 EXPECT_EQ(false, absent_custom_default.is_present());
28 EXPECT_EQ(1, absent_custom_default.value());
29
30 Element<int> present(2, true);
31 EXPECT_EQ(true, present.is_present());
32 EXPECT_EQ(2, present.value());
33 }
34
TEST_F(ElementTest,Assignment)35 TEST_F(ElementTest, Assignment) {
36 Element<int> e;
37
38 e.Set(42, true);
39 EXPECT_EQ(true, e.is_present());
40 EXPECT_EQ(42, e.value());
41
42 *e.mutable_value() = 0;
43 EXPECT_EQ(true, e.is_present());
44 EXPECT_EQ(0, e.value());
45 }
46
47 } // namespace
48