static int _testLinkedListToArray(void) { LinkedList l = newLinkedList(); CharString* arr; appendItemToList(l, newCharStringWithCString("one")); appendItemToList(l, newCharStringWithCString("two")); arr = (CharString*)linkedListToArray(l); assertNotNull(arr); assertCharStringEquals((CharString)arr[0], "one"); assertCharStringEquals((CharString)arr[1], "two"); assertIsNull(arr[2]); return 0; }
static int _testNewFileDefault(void) { File f = newFile(); assertNotNull(f); assertCharStringEquals(f->absolutePath, ""); assertIntEquals(f->fileType, kFileTypeInvalid); return 0; }
static int _testNewPluginVst2xIdWithIntId(void) { PluginVst2xId id = newPluginVst2xIdWithId(0x61626364); assertUnsignedLongEquals(0x61626364l, id->id); assertCharStringEquals("abcd", id->idString); freePluginVst2xId(id); return 0; }
static int _testNewPluginVst2xIdWithNullStringId(void) { PluginVst2xId id = newPluginVst2xIdWithStringId(NULL); assertUnsignedLongEquals(ZERO_UNSIGNED_LONG, id->id); assertCharStringEquals(PLUGIN_VST2X_ID_UNKNOWN, id->idString); freePluginVst2xId(id); return 0; }
static int _testNewPluginVst2xIdWithZeroIntId(void) { PluginVst2xId id = newPluginVst2xIdWithId(0); assertUnsignedLongEquals(ZERO_UNSIGNED_LONG, id->id); assertCharStringEquals(EMPTY_STRING, id->idString); freePluginVst2xId(id); return 0; }
static int _testNewObject(void) { CharString c = newCharStringWithCString(TEST_PRESET_FILENAME); PluginPreset p = newPluginPreset(PRESET_TYPE_FXP, c); assertIntEquals(p->presetType, PRESET_TYPE_FXP); assertCharStringEquals(p->presetName, TEST_PRESET_FILENAME); freePluginPreset(p); freeCharString(c); return 0; }
static int _testNewMidiSource(void) { CharString c = newCharStringWithCString(TEST_MIDI_FILENAME); MidiSource m = newMidiSource(MIDI_SOURCE_TYPE_FILE, c); assertCharStringEquals(TEST_MIDI_FILENAME, m->sourceName); assertIntEquals(MIDI_SOURCE_TYPE_FILE, m->midiSourceType); freeMidiSource(m); freeCharString(c); return 0; }
static int _testNewPluginVst2xIdWithStringId(void) { CharString c = newCharStringWithCString("abcd"); PluginVst2xId id = newPluginVst2xIdWithStringId(c); assertUnsignedLongEquals(0x61626364l, id->id); assertCharStringEquals(c->data, id->idString); freePluginVst2xId(id); freeCharString(c); return 0; }
static int _testNewPluginVst2xIdWithEmptyStringId(void) { CharString empty = newCharStringWithCString(EMPTY_STRING); PluginVst2xId id = newPluginVst2xIdWithStringId(empty); assertUnsignedLongEquals(ZERO_UNSIGNED_LONG, id->id); assertCharStringEquals(PLUGIN_VST2X_ID_UNKNOWN, id->idString); freePluginVst2xId(id); freeCharString(empty); return 0; }
static int _testNewPluginVst2xIdWithInvalidStringId(void) { CharString c = newCharStringWithCString("a"); PluginVst2xId id = newPluginVst2xIdWithStringId(c); assertUnsignedLongEquals(ZERO_UNSIGNED_LONG, id->id); assertCharStringEquals(PLUGIN_VST2X_ID_UNKNOWN, id->idString); freePluginVst2xId(id); freeCharString(c); return 0; }
static int _testLinkedListToArray(void) { LinkedList l = newLinkedList(); CharString* arr; CharString c; linkedListAppend(l, newCharStringWithCString("one")); linkedListAppend(l, newCharStringWithCString("two")); arr = (CharString*)linkedListToArray(l); assertNotNull(arr); c = (CharString)arr[0]; assertCharStringEquals(c, "one"); c = (CharString)arr[1]; assertCharStringEquals(c, "two"); assertIsNull(arr[2]); free(arr); freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString); return 0; }
static int _testAppendItemToList(void) { LinkedList l = newLinkedList(); CharString c = newCharString(); charStringCopyCString(c, TEST_ITEM_STRING); linkedListAppend(l, c); assertNotNull(l->item); assertCharStringEquals(((CharString)l->item), TEST_ITEM_STRING); assertIsNull(l->nextItem); freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString); return 0; }
static int _testAppendMultipleItemsToList(void) { LinkedListIterator i; LinkedList l = newLinkedList(); CharString c = newCharString(); CharString c2 = newCharString(); charStringCopyCString(c, TEST_ITEM_STRING); charStringCopyCString(c2, OTHER_TEST_ITEM_STRING); linkedListAppend(l, c); linkedListAppend(l, c2); assertNotNull(l->item); assertCharStringEquals(((CharString)l->item), TEST_ITEM_STRING); assertNotNull(l->nextItem); i = l->nextItem; assertNotNull(i->item); assertCharStringEquals(((CharString)i->item), OTHER_TEST_ITEM_STRING); assertIsNull(i->nextItem); assertIntEquals(linkedListLength(l), 2); freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString); return 0; }
static int _testPluginFactoryNullRoot(void) { CharString silence = newCharStringWithCString("mrs_silence"); Plugin p = pluginFactory(silence, NULL); assertNotNull(p); assertIntEquals(PLUGIN_TYPE_INTERNAL, p->interfaceType); assertCharStringEquals(silence->data, p->pluginName); freeCharString(silence); freePlugin(p); return 0; }
static int _testGetPlatformName(void) { CharString p = getPlatformName(); #if LINUX assertCharStringContains(p, "Linux"); #elif MACOSX assertCharStringContains(p, "Mac OS X"); #elif WINDOWS assertCharStringContains(p, "Windows"); #else assertCharStringEquals(p, "Unsupported platform"); #endif freeCharString(p); return 0; }
static int _testBuildAbsolutePathWithFileExtensionTwice(void) { CharString d = newCharStringWithCString(ROOT_DIRECTORY); CharString out = newCharString(); CharString f = newCharStringWithCString(TEST_FILENAME); CharString expected = newCharString(); snprintf(expected->data, expected->capacity, "%s%c%s", ROOT_DIRECTORY, PATH_DELIMITER, TEST_FILENAME); buildAbsolutePath(d, f, "txt", out); assertCharStringEquals(out, expected->data); freeCharString(d); freeCharString(out); freeCharString(f); freeCharString(expected); return 0; }
static int _testGetFileDirname(void) { CharString filename = newCharStringWithCString(ABSOLUTE_TEST_FILENAME); CharString expected = newCharString(); CharString result = newCharString(); #if UNIX charStringCopyCString(expected, "/tmp"); #elif WINDOWS charStringCopyCString(expected, "C:\\Temp"); #endif getFileDirname(filename, result); assertCharStringEquals(result, expected->data); freeCharString(filename); freeCharString(expected); freeCharString(result); return 0; }
static int _testListDirectory(void) { CharString tempDir = _fileUtilitiesMakeTempDir(); CharString tempFile = newCharString(); CharString filename; CharString testFilename = newCharStringWithCString(TEST_FILENAME); LinkedList l; FILE *f; buildAbsolutePath(tempDir, testFilename, NULL, tempFile); f = fopen(tempFile->data, "w"); assertNotNull(f); fclose(f); l = listDirectory(tempDir); assertIntEquals(linkedListLength(l), 1); filename = (CharString)l->item; assertCharStringEquals(filename, TEST_FILENAME); removeDirectory(tempDir); freeCharString(tempDir); freeCharString(tempFile); freeCharString(testFilename); freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString); return 0; }
static int _testGetShortPlatformName(void) { CharString p = newCharStringWithCString(getShortPlatformName()); #if LINUX if(isHost64Bit() && isExecutable64Bit()) { assertCharStringEquals(p, "Linux-x86_64"); } else { assertCharStringEquals(p, "Linux-i686"); } #elif MACOSX assertCharStringEquals(p, "Mac OS X"); #elif WINDOWS if(isHost64Bit() && isExecutable64Bit()) { assertCharStringEquals(p, "Windows 64-bit"); } else { assertCharStringEquals(p, "Windows 32-bit"); } #else assertCharStringEquals(p, "Unsupported"); #endif freeCharString(p); return 0; }
static int _testGetFileExtension(void) { CharString c = newCharStringWithCString(getFileExtension(TEST_FILENAME)); assertCharStringEquals(c, "txt"); freeCharString(c); return 0; }
static int _testGetFileBasename(void) { CharString c = newCharStringWithCString(getFileBasename(ABSOLUTE_TEST_FILENAME)); assertCharStringEquals(c, TEST_FILENAME); freeCharString(c); return 0; }