Skip to content

Commit

Permalink
[2_2] add blackbox_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuanmxc committed Aug 7, 2023
1 parent 69ebde6 commit 9989327
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tests/Kernel/Abstractions/blackbox_test.cpp
Original file line number Diff line number Diff line change
@@ -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<SI> (-2147483648);
blackbox box2 = close_box<SN> (2147483647);
blackbox box3 = close_box<HI> (32767);
blackbox box4 = close_box<HN> (-32768);
blackbox box5 = close_box<QI> (-128);
blackbox box6 = close_box<QN> (255);
blackbox box7 = close_box<DI> (LLONG_MAX);
blackbox box8 = close_box<DN> (ULLONG_MAX);
blackbox box9 = close_box<pointer> (0);
blackbox box01= close_box<SI> (1);
blackbox box02= close_box<SN> (1);
blackbox box03= close_box<HI> (1);
blackbox box06= close_box<QN> (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<SI> (-2147483648);
blackbox box2 = close_box<SN> (2147483647);
blackbox box3 = close_box<HI> (32767);
blackbox box6 = close_box<QN> (255);
blackbox box01= close_box<SI> (1);
blackbox box02= close_box<SN> (1);
blackbox box03= close_box<HI> (1);
blackbox box06= close_box<QN> (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") {}

0 comments on commit 9989327

Please sign in to comment.