Changeset 8e5f39d in mainline for uspace/app/nav/test/panel.c
- Timestamp:
- 2021-10-07T17:17:36Z (4 years ago)
- Children:
- 166aba54
- Parents:
- 3b67e95
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/test/panel.c
r3b67e95 r8e5f39d 29 29 #include <errno.h> 30 30 #include <pcut/pcut.h> 31 #include <stdio.h> 32 #include <vfs/vfs.h> 31 33 #include "../panel.h" 32 34 … … 194 196 } 195 197 198 /** panel_clear_entries() removes all entries from panel */ 199 PCUT_TEST(clear_entries) 200 { 201 panel_t *panel; 202 errno_t rc; 203 204 rc = panel_create(NULL, &panel); 205 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 206 207 rc = panel_entry_append(panel, "a", 1); 208 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 209 210 rc = panel_entry_append(panel, "b", 2); 211 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 212 213 PCUT_ASSERT_INT_EQUALS(2, list_count(&panel->entries)); 214 215 panel_clear_entries(panel); 216 PCUT_ASSERT_INT_EQUALS(0, list_count(&panel->entries)); 217 218 panel_destroy(panel); 219 } 220 221 /** panel_read_dir() reads the contents of a directory */ 222 PCUT_TEST(read_dir) 223 { 224 panel_t *panel; 225 panel_entry_t *entry; 226 char buf[L_tmpnam]; 227 char *fname; 228 char *p; 229 errno_t rc; 230 FILE *f; 231 int rv; 232 233 /* Create name for temporary directory */ 234 p = tmpnam(buf); 235 PCUT_ASSERT_NOT_NULL(p); 236 237 /* Create temporary directory */ 238 rc = vfs_link_path(p, KIND_DIRECTORY, NULL); 239 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 240 241 rv = asprintf(&fname, "%s/%s", p, "a"); 242 PCUT_ASSERT_TRUE(rv >= 0); 243 244 f = fopen(fname, "wb"); 245 PCUT_ASSERT_NOT_NULL(f); 246 247 rv = fprintf(f, "X"); 248 PCUT_ASSERT_TRUE(rv >= 0); 249 250 rv = fclose(f); 251 PCUT_ASSERT_INT_EQUALS(0, rv); 252 253 rc = panel_create(NULL, &panel); 254 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 255 256 rc = panel_read_dir(panel, p); 257 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 258 259 PCUT_ASSERT_INT_EQUALS(1, list_count(&panel->entries)); 260 261 entry = panel_first(panel); 262 PCUT_ASSERT_NOT_NULL(entry); 263 PCUT_ASSERT_STR_EQUALS("a", entry->name); 264 // PCUT_ASSERT_INT_EQUALS(1, entry->size); 265 266 panel_destroy(panel); 267 268 rv = remove(fname); 269 PCUT_ASSERT_INT_EQUALS(0, rv); 270 271 rv = remove(p); 272 PCUT_ASSERT_INT_EQUALS(0, rv); 273 free(fname); 274 } 275 196 276 /** panel_first() returns valid entry or @c NULL as appropriate */ 197 277 PCUT_TEST(first)
Note:
See TracChangeset
for help on using the changeset viewer.