Path: blob/main_old/src/common/Optional_unittest.cpp
1693 views
//1// Copyright 2015 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// Unit tests for ANGLE's Optional helper class.6//78#include "gmock/gmock.h"9#include "gtest/gtest.h"1011#include "common/Optional.h"1213namespace14{1516TEST(OptionalTest, BasicInvalid)17{18Optional<int> testInvalid;19ASSERT_FALSE(testInvalid.valid());20ASSERT_EQ(Optional<int>::Invalid(), testInvalid);21}2223TEST(OptionalTest, BasicValid)24{25Optional<int> testValid(3);26ASSERT_TRUE(testValid.valid());27ASSERT_EQ(3, testValid.value());28ASSERT_NE(Optional<int>::Invalid(), testValid);29}3031TEST(OptionalTest, Copies)32{33Optional<int> testValid(3);34Optional<int> testInvalid;3536Optional<int> testCopy = testInvalid;37ASSERT_FALSE(testCopy.valid());38ASSERT_EQ(testInvalid, testCopy);3940testCopy = testValid;41ASSERT_TRUE(testCopy.valid());42ASSERT_EQ(3, testCopy.value());43ASSERT_EQ(testValid, testCopy);44}4546} // namespace474849