예제 #1
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  Tuple *t = dict_read_first(iterator);
  
  while(t != NULL) {
    switch (t->key) {
      case NUM_MENU_ITEMS:
        s_num_menu_items = t->value->uint16;
        break;
      case POSTS:
      {
        ProcessingState *state = data_processor_create(t->value->cstring, '|');
        uint8_t num_strings = data_processor_count(state);
        s_strings = malloc(sizeof(char*) * num_strings);
        for (uint8_t n = 0; n < num_strings; n += 1) {
          s_strings[n] = data_processor_get_string(state);
        }
        data_processor_destroy(state);
        break;
      }
      case COMMENTS:
        break;
    }
    // Get next pair, if any
    t = dict_read_next(iterator);
  }
  
  layer_mark_dirty(menu_layer_get_layer(s_menu_layer));
}
예제 #2
0
// The count of a NULL state should be 0.
static char* test_count_null_state(void) {
  int count = data_processor_count(NULL);
  mu_assert(0 == count, "Count of NULL state not calculated correctly");
  return 0;
}
예제 #3
0
// The count of an empty string should be 0.
static char* test_count_none(void) {
  data_processor_init("", '|');
  int count = data_processor_count(data_processor_get_global());
  mu_assert(0 == count, "Count of zero subelements not calculated correctly");
  return 0;
}
예제 #4
0
// The count of multiple subelements should be equal to the number of subelements.
static char* test_count_multiple(void) {
  data_processor_init("Hello|Goodbye||", '|');
  int count = data_processor_count(data_processor_get_global());
  mu_assert(4 == count, "Count of multiple subelements not calculated correctly");
  return 0;
}
예제 #5
0
// The count of a single subelement should be 1.
static char* test_count_single(void) {
  data_processor_init("Hello", '|');
  int count = data_processor_count(data_processor_get_global());
  mu_assert(1 == count, "Count of single subelement not calculated correctly");
  return 0;
}