From 9989327b94a6931b56013472fc4110b5e7ef1c16 Mon Sep 17 00:00:00 2001 From: Origin-yy <1657615110@qq.com> Date: Mon, 7 Aug 2023 17:36:43 +0800 Subject: [PATCH] [2_2] add blackbox_test --- tests/Kernel/Abstractions/blackbox_test.cpp | 82 +++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/Kernel/Abstractions/blackbox_test.cpp diff --git a/tests/Kernel/Abstractions/blackbox_test.cpp b/tests/Kernel/Abstractions/blackbox_test.cpp new file mode 100644 index 000000000..c936192f3 --- /dev/null +++ b/tests/Kernel/Abstractions/blackbox_test.cpp @@ -0,0 +1,82 @@ +/* + * @file blackbox_test.cpp + * @author yuanmxc + * @date 2023-8-7 + * + * Copyright (c) Year Company Name. All rights reserved. + * + * @brief A test for blackbox. + */ + +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN + +#include "blackbox.hpp" +#include "doctest/doctest.h" +#include "string.hpp" + +TEST_CASE ("test for get_type()") { + blackbox box0; + blackbox box1 = close_box (-2147483648); + blackbox box2 = close_box (2147483647); + blackbox box3 = close_box (32767); + blackbox box4 = close_box (-32768); + blackbox box5 = close_box (-128); + blackbox box6 = close_box (255); + blackbox box7 = close_box (LLONG_MAX); + blackbox box8 = close_box (ULLONG_MAX); + blackbox box9 = close_box (0); + blackbox box01= close_box (1); + blackbox box02= close_box (1); + blackbox box03= close_box (1); + blackbox box06= close_box (255); + CHECK_EQ (box0->get_type () == 0, true); + CHECK_EQ (box1->get_type () == -9, true); + CHECK_EQ (box2->get_type () == -8, true); + CHECK_EQ (box3->get_type () == -7, true); + CHECK_EQ (box4->get_type () == -6, true); + CHECK_EQ (box5->get_type () == -5, true); + CHECK_EQ (box6->get_type () == -4, true); + CHECK_EQ (box7->get_type () == -3, true); + CHECK_EQ (box8->get_type () == -2, true); + CHECK_EQ (box9->get_type () == -1, true); +} + +TEST_CASE ("test for equal(), operator== and operator!=") { + blackbox box0; + blackbox box1 = close_box (-2147483648); + blackbox box2 = close_box (2147483647); + blackbox box3 = close_box (32767); + blackbox box6 = close_box (255); + blackbox box01= close_box (1); + blackbox box02= close_box (1); + blackbox box03= close_box (1); + blackbox box06= close_box (255); + CHECK_EQ (box0 == box0, true); + CHECK_EQ (box1 == box0, true); + CHECK_EQ (box1 == box01, true); + CHECK_EQ (box2 == box02, true); + CHECK_EQ (box3 == box03, true); + CHECK_EQ (box6 == box06, true); + + CHECK_EQ (box1 != box2, true); + CHECK_EQ (box2 != box03, true); + CHECK_EQ (box3 != box06, true); +} + +TEST_CASE ("") {} + +TEST_CASE ("test ") {} + +TEST_CASE ("test") {} + +TEST_CASE ("test") {} + +TEST_CASE ("test") {} + +TEST_CASE ("test") {} + +TEST_CASE ("test") {} + +TEST_CASE ("test") {} + +TEST_CASE ("test") {}