Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahans committed Jan 28, 2024
1 parent ac041b2 commit 794e68f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions exercises/practice/pop-count/.meta/example.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "pop_count.h"

int egg_count(int value)
unsigned int egg_count(unsigned int value)
{
int count = 0;
unsigned int count = 0;
while (value != 0) {
count += value & 1;
value = value >> 1;
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/pop-count/.meta/example.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef POP_COUNT_H
#define POP_COUNT_H

int egg_count(int value);
unsigned int egg_count(unsigned int value);

#endif
8 changes: 6 additions & 2 deletions exercises/practice/pop-count/test_pop_count.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,37 @@ void tearDown(void)

static void test_0_eggs(void)
{
const int expected = 0;
const unsigned int expected = 0;
TEST_ASSERT_EQUAL_INT(expected, egg_count(0));
}

static void test_1_eggs(void)
{
TEST_IGNORE();
const int expected = 1;
TEST_ASSERT_EQUAL_INT(expected, egg_count(16));
}

static void test_4_eggs(void)
{
TEST_IGNORE();
const int expected = 4;
TEST_ASSERT_EQUAL_INT(expected, egg_count(89));
}

static void test_13_eggs(void)
{
TEST_IGNORE();
const int expected = 13;
TEST_ASSERT_EQUAL_INT(expected, egg_count(2000000000));
}

int main(void)
{
UnityBegin("test_prime_factors.c");
UnityBegin("test_pop_count.c");

RUN_TEST(test_0_eggs);

RUN_TEST(test_1_eggs);
RUN_TEST(test_4_eggs);
RUN_TEST(test_13_eggs);
Expand Down

0 comments on commit 794e68f

Please sign in to comment.