xref: /openbmc/google-misc/dhcp-done/subprojects/ncsid/test/iface_test.cpp (revision dab96f131fb3a46d93f1093feccc9095d8589ece)
1* // Copyright 2021 Google LLC
2* //
3* // Licensed under the Apache License, Version 2.0 (the "License");
4* // you may not use this file except in compliance with the License.
5* // You may obtain a copy of the License at
6* //
7* //      http://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,
11* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* // See the License for the specific language governing permissions and
13* // limitations under the License.
14* 
15* #include "net_iface_mock.h"
16* 
17* #include <gtest/gtest.h>
18* 
19* TEST(TestIFace, TestGetIndex)
20* {
21*     mock::IFace iface_mock;
22* 
23*     constexpr int test_index = 5;
24*     iface_mock.index = test_index;
25* 
26*     EXPECT_EQ(test_index, iface_mock.get_index());
27* }
28* 
29* TEST(TestIFace, TestSetClearFlags)
30* {
31*     mock::IFace iface_mock;
32* 
33*     const short new_flags = 0xab;
34*     iface_mock.set_sock_flags(0, new_flags);
35*     EXPECT_EQ(new_flags, new_flags & iface_mock.flags);
36*     iface_mock.clear_sock_flags(0, 0xa0);
37*     EXPECT_EQ(0xb, new_flags & iface_mock.flags);
38* }
39*