Esempio n. 1
0
// Mixed values should be simultaneously be extractable from multiple local states.
static char* test_multiple_local_mixed(void) {
  ProcessingState* state1 = data_processor_create("8|This is a string!", '|');
  ProcessingState* state2 = data_processor_create("0|6765444", '|');
  int num1 = data_processor_get_int(state1);
  bool boolean1 = data_processor_get_bool(state2);
  char* string1 = data_processor_get_string(state1);
  int num2 = data_processor_get_int(state2);
  mu_assert(8 == num1 && 0 == strcmp("This is a string!", string1) && false == boolean1 && 6765444 == num2, "Mixed values not extracted from global state");
  return 0;
}
Esempio n. 2
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));
}
void data_processor_init(char* data, char delim) {
  data_processor_deinit();
  global = data_processor_create(data, delim);
}