forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptValueTest.cpp
More file actions
38 lines (31 loc) · 807 Bytes
/
OptValueTest.cpp
File metadata and controls
38 lines (31 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "hermes/Support/OptValue.h"
#include "gtest/gtest.h"
using namespace hermes;
namespace {
template <typename T>
void run1BasicTest() {
T val1{};
T val2 = !val1;
OptValue<T> empty1{};
OptValue<T> empty2(llvh::None);
OptValue<T> filled1(val1);
OptValue<T> filled2(val2);
ASSERT_EQ(empty1, empty2);
ASSERT_NE(empty1, filled1);
ASSERT_EQ(filled1, filled1);
ASSERT_NE(filled1, filled2);
ASSERT_EQ(*filled1, val1);
ASSERT_EQ(filled2.getValue(), val2);
}
TEST(OptValue, Basics) {
run1BasicTest<int>();
run1BasicTest<double>();
run1BasicTest<bool>();
}
} // end anonymous namespace