Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 11 additions & 27 deletions test/test_isogram.c
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this found its way into the wrong file?
can you move this to iscogram.c

#include "../src/isogram.h"
#include "vendor/unity.h"
#include <stdlib.h>

void setUp(){}

void tearDown(){}

// this is a unit test
void test_empty_string(void) {
TEST_ASSERT_TRUE(is_isogram(""));
}
bool is_isogram(const char phrase[]){

// this is a unit test
void test_short_isograms(void) {
TEST_ASSERT_TRUE(is_isogram("abc"));
TEST_ASSERT_TRUE(is_isogram("opq"));
}
char string [] = "Wort"

void test_short_non_isograms(void) {
TEST_ASSERT_FALSE(is_isogram("abca"));
TEST_ASSERT_FALSE(is_isogram("opqp"));
}
for (char candidate = 'a'; candidate <= 'z'; candidate++){
int counter = 0;

for (int i=0; string[i] != 0; i++){ //until it is not 0 (/0 is end of string)
if string[i] == candidate{
counter++;
}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return is missing? probably check

if counter > 1 {
   return false;
}

int main(void) {
UnityBegin("isIsogram");
}

RUN_TEST(test_empty_string);
RUN_TEST(test_short_isograms);
RUN_TEST(test_short_non_isograms);

UnityEnd();
return 0;
}
}