1 // Copyright 2022 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include <cstddef>
16
17 #include "pw_build/test_blob.h"
18 #include "pw_unit_test/framework.h"
19
20 namespace {
21
22 static_assert(test::ns::kFirstBlob0123.size() == 4);
23 static_assert(test::ns::kSecondBlob0123.size() == 4);
24
TEST(CcBlobLibraryTest,FirstBlobContentsMatch)25 TEST(CcBlobLibraryTest, FirstBlobContentsMatch) {
26 EXPECT_EQ(test::ns::kFirstBlob0123[0], std::byte{0});
27 EXPECT_EQ(test::ns::kFirstBlob0123[1], std::byte{1});
28 EXPECT_EQ(test::ns::kFirstBlob0123[2], std::byte{2});
29 EXPECT_EQ(test::ns::kFirstBlob0123[3], std::byte{3});
30 }
31
TEST(CcBlobLibraryTest,SecondBlobContentsMatch)32 TEST(CcBlobLibraryTest, SecondBlobContentsMatch) {
33 EXPECT_EQ(test::ns::kSecondBlob0123[0], std::byte{0});
34 EXPECT_EQ(test::ns::kSecondBlob0123[1], std::byte{1});
35 EXPECT_EQ(test::ns::kSecondBlob0123[2], std::byte{2});
36 EXPECT_EQ(test::ns::kSecondBlob0123[3], std::byte{3});
37 }
38
TEST(CcBlobLibraryTest,FirstBlobAlignedTo512)39 TEST(CcBlobLibraryTest, FirstBlobAlignedTo512) {
40 // This checks that the variable is aligned to 512, but cannot guarantee that
41 // alignas was specified correctly, since it could be aligned to 512 by
42 // coincidence.
43 const uintptr_t addr = reinterpret_cast<uintptr_t>(&test::ns::kFirstBlob0123);
44 constexpr uintptr_t kAlignmentMask = static_cast<uintptr_t>(512 - 1);
45 EXPECT_EQ(addr & kAlignmentMask, 0u);
46 }
47
48 } // namespace
49