Upload upstream chromium 67.0.3396
[platform/framework/web/chromium-efl.git] / base / bit_cast_unittest.cc
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5
6 #include "base/bit_cast.h"
7
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace base {
11 namespace {
12
13 TEST(BitCastTest, FloatIntFloat) {
14   float f = 3.1415926f;
15   int i = bit_cast<int32_t>(f);
16   float f2 = bit_cast<float>(i);
17   EXPECT_EQ(f, f2);
18 }
19
20 struct A {
21   int x;
22 };
23
24 TEST(BitCastTest, StructureInt) {
25   A a = { 1 };
26   int b = bit_cast<int>(a);
27   EXPECT_EQ(1, b);
28 }
29
30 }  // namespace
31 }  // namespace base