Beispiel #1
0
int
main(int argc, char *argv[]) 
{
  raptor_sequence* seq=raptor_new_sequence(NULL, (raptor_print_handler*)raptor_sequence_print_string);
  char *s;

  program=argv[0];
  

  raptor_sequence_set_at(seq, 0, (void*)"first");

  raptor_sequence_push(seq, (void*)"third");

  raptor_sequence_shift(seq, (void*)"second");

  s=(char*)raptor_sequence_get_at(seq, 0);
  assert_match(raptor_sequence_get_at, s, "second");

  s=(char*)raptor_sequence_get_at(seq, 1);
  assert_match(raptor_sequence_get_at, s, "first");
  
  s=(char*)raptor_sequence_get_at(seq, 2);
  assert_match(raptor_sequence_get_at, s, "third");
  
  if(raptor_sequence_size(seq) !=3)
    exit(1);

  fprintf(stderr, "%s: sequence after additions: ", program);
  raptor_sequence_print(seq, stderr);
  fputc('\n', stderr);

  /* now made alphabetical i.e. first, second, third */
  raptor_sequence_sort(seq, raptor_compare_strings);

  fprintf(stderr, "%s: sequence after sort: ", program);
  raptor_sequence_print(seq, stderr);
  fputc('\n', stderr);

  s=(char*)raptor_sequence_pop(seq);
  assert_match(raptor_sequence_get_at, s, "third");

  if(raptor_sequence_size(seq) !=2)
    exit(1);

  fprintf(stderr, "%s: sequence after pop: ", program);
  raptor_sequence_print(seq, stderr);
  fputc('\n', stderr);

  s=(char*)raptor_sequence_unshift(seq);
  assert_match(raptor_sequence_get_at, s, "first");

  if(raptor_sequence_size(seq) !=1)
    exit(1);

  fprintf(stderr, "%s: sequence after unshift: ", program);
  raptor_sequence_print(seq, stderr);
  fputc('\n', stderr);

  s=(char*)raptor_sequence_get_at(seq, 0);
  assert_match(raptor_sequence_get_at, s, "second");
  
  raptor_free_sequence(seq);

  return (0);
}
Beispiel #2
0
int
main(void)
{
    assert_match("to be or not to be", "to be or not to be");

    assert_no_match("to be or not to be ", "to be or not to be");
    assert_no_match("jkjke", "jkjk");
    assert_no_match("ijkjke", "ijkjk");
    assert_no_match("iijkjke", "iijkjk");
    assert_no_match("iiijkjke", "iiijkjk");
    assert_no_match("iiiijkjke", "iiiijkjk");
    assert_no_match("iiiiijkjke", "iiiiijkjk");
    assert_no_match("iiiiiijkjke", "iiiiiijkjk");
    assert_no_match("iiiiiiijkjke", "iiiiiiijkjk");
    assert_no_match("iiiiiiiijkjke", "iiiiiiiijkjk");
    assert_no_match("ab", "bb");

    {
        const uint8_t a[3] = { 0, 0, 0 };
        const uint8_t b[5] = { 0, 0, 0, 0, 0 };

        uint64_t left  = seahash(a, 3 * sizeof(uint8_t));
        uint64_t right = seahash(b, 5 * sizeof(uint8_t));

        if (left == right) {
            error_occurred("Hash was found to be zero sensitive");
        }
    }

    {
        const uint8_t a[4] = { 1, 2, 3, 4 };
        const uint8_t b[5] = { 1, 0, 2, 3, 4 };

        uint64_t left  = seahash(a, 4 * sizeof(uint8_t));
        uint64_t right = seahash(b, 5 * sizeof(uint8_t));

        if (left == right) {
            error_occurred("Hash was found to be zero sensitive");
        }
    }

    {
        const uint8_t a[4] = { 1, 2, 3, 4 };
        const uint8_t b[6] = { 1, 0, 0, 2, 3, 4 };

        uint64_t left  = seahash(a, 4 * sizeof(uint8_t));
        uint64_t right = seahash(b, 6 * sizeof(uint8_t));

        if (left == right) {
            error_occurred("Hash was found to be zero sensitive");
        }
    }

    {
        const uint8_t a[4] = { 1, 2, 3, 4 };
        const uint8_t b[5] = { 1, 2, 3, 4, 0 };

        uint64_t left  = seahash(a, 4 * sizeof(uint8_t));
        uint64_t right = seahash(b, 5 * sizeof(uint8_t));

        if (left == right) {
            error_occurred("Hash was found to be zero sensitive");
        }
    }

    return EXIT_SUCCESS;
}