Skip to content
Snippets Groups Projects
Select Git revision
  • 14eaa0f41ed7f4ff4cca81cf42e3e85a501b1403
  • tutorial-1 default protected
  • main
3 results

test_hamming.c

Blame
  • Forked from mactavish96 / ALP4-Tutorials
    123 commits behind the upstream repository.
    user avatar
    Mactavish authored
    14eaa0f4
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_hamming.c 1.47 KiB
    #include "../unity/unity.h"
    #include "hamming.h"
    
    void setUp(void) {}
    
    void tearDown(void) {}
    
    static void test_empty_strands(void) { TEST_ASSERT_EQUAL(0, compute("", "")); }
    
    static void test_single_identical_strands(void) {
      TEST_ASSERT_EQUAL(0, compute("A", "A"));
    }
    
    static void test_single_letter_different_strands(void) {
      TEST_ASSERT_EQUAL(1, compute("G", "T"));
    }
    
    static void test_long_identical_strands(void) {
      TEST_ASSERT_EQUAL(0, compute("GGACTGAAATCTG", "GGACTGAAATCTG"));
    }
    
    static void test_long_different_strands(void) {
      TEST_ASSERT_EQUAL(9, compute("GGACGGATTCTG", "AGGACGGATTCT"));
    }
    
    static void test_disallow_first_strand_when_longer(void) {
      TEST_ASSERT_EQUAL(-1, compute("AATG", "AAA"));
    }
    
    static void test_disallow_second_strand_when_longer(void) {
      TEST_ASSERT_EQUAL(-1, compute("ATA", "AGTG"));
    }
    
    static void test_disallow_empty_first_strand(void) {
      TEST_ASSERT_EQUAL(-1, compute("", "G"));
    }
    
    static void test_disallow_empty_second_strand(void) {
      TEST_ASSERT_EQUAL(-1, compute("G", ""));
    }
    
    int main(void) {
      UnityBegin("test_hamming.c");
    
      RUN_TEST(test_empty_strands);
      RUN_TEST(test_single_identical_strands);
      RUN_TEST(test_single_letter_different_strands);
      RUN_TEST(test_long_identical_strands);
      RUN_TEST(test_long_different_strands);
      RUN_TEST(test_disallow_first_strand_when_longer);
      RUN_TEST(test_disallow_second_strand_when_longer);
      RUN_TEST(test_disallow_empty_first_strand);
      RUN_TEST(test_disallow_empty_second_strand);
    
      return UnityEnd();
    }