Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyscarborough committed Jan 24, 2023
1 parent edadda1 commit f8cbb07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/registers/loopy_test.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include <gtest/gtest.h>
#include "../../src/registers/loopy.h"

TEST(LoopRegisterTests, test_set) {
TEST(LoopyRegister, set) {
LoopyRegister reg;
reg.set_value(0b1111111111);
EXPECT_EQ(reg.get_value(), 0b1111111111);
EXPECT_EQ(reg.get_value(), 0b0000000000000000);
reg.set(LoopyRegister::CoarseX, 0b11111);
reg.set(LoopyRegister::CoarseY, 0b11111);
EXPECT_EQ(reg.get_value(), 0b0000001111111111);
reg.set(LoopyRegister::CoarseY, 0b10101);
EXPECT_EQ(reg.get_value(), 0b1010111111);
reg.set(LoopyRegister::Unused, 1);
EXPECT_EQ(reg.get_value(), 0b0000001010111111);
reg.set(LoopyRegister::Unused, 0b1);
EXPECT_EQ(reg.get_value(), 0b1000001010111111);
reg.set(LoopyRegister::Unused, 0);
reg.set(LoopyRegister::Unused, 0b0);
EXPECT_EQ(reg.get_value(), 0b0000001010111111);
reg.set(LoopyRegister::FineY, 0b011);
EXPECT_EQ(reg.get_value(), 0b0011001010111111);
Expand Down
12 changes: 12 additions & 0 deletions test/utils_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <gtest/gtest.h>
#include "../src/utils.h"

TEST(utils, test_count_trailing_zeroes_when_zero) {
EXPECT_EQ(0, utils::count_trailing_zeroes(0));
}

TEST(utils, test_count_trailing_zeroes_when_nonzero) {
EXPECT_EQ(5, utils::count_trailing_zeroes(0b100100000));
EXPECT_EQ(0, utils::count_trailing_zeroes(0b111));
EXPECT_EQ(1, utils::count_trailing_zeroes(0b1010));
}

0 comments on commit f8cbb07

Please sign in to comment.