• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 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 "pw_bluetooth_proxy/internal/rfcomm_fcs.h"
16 
17 #include "pw_unit_test/framework.h"
18 
19 namespace pw::bluetooth::proxy {
20 
21 namespace {
22 
TEST(RfcommFcsTest,Uih)23 TEST(RfcommFcsTest, Uih) {
24   std::array<uint8_t, 2> uih{
25       0x19,
26       0xEF,
27   };
28   auto view = emboss::MakeRfcommFrameView(uih.data(), uih.size());
29   EXPECT_EQ(RfcommFcs(view), 0x55);
30 }
31 
TEST(RfcommFcsTest,Sabm)32 TEST(RfcommFcsTest, Sabm) {
33   std::array<uint8_t, 3> sabm{
34       0x19,
35       0x2F,
36       0x01,
37   };
38   auto view = emboss::MakeRfcommFrameView(sabm.data(), sabm.size());
39   EXPECT_EQ(RfcommFcs(view), 0xA7);
40 }
41 
TEST(RfcommFcsTest,SabmExtended)42 TEST(RfcommFcsTest, SabmExtended) {
43   std::array<uint8_t, 4> sabm_extended_length{
44       0x19,
45       0x2F,
46       0x00,
47       0x01,
48   };
49   auto view = emboss::MakeRfcommFrameView(sabm_extended_length.data(),
50                                           sabm_extended_length.size());
51   EXPECT_EQ(RfcommFcs(view), 0x61);
52 }
53 
54 }  // namespace
55 
56 }  // namespace pw::bluetooth::proxy
57