Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: base/bit_cast_unittest.cc

Issue 1925683002: Add simple bit_cast unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bit_cast.h, fix windows test compile Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/bit_cast.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
31 } // namespace
32 } // namespace base
OLDNEW
« no previous file with comments | « base/bit_cast.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698