/*- * Copyright (c) 2013 Jan Breuer * Richard.hmm * Copyright (c) 2012 Jan Breuer * * All Rights Reserved * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * File: test_scpi_utils.c * Author: Jan Breuer * * Created on 26.11.2012, 11:22:00 */ #include #include #include #include #include "CUnit/Basic.h" #include "scpi/scpi.h" #include "../src/utils_private.h" /* * CUnit Test Suite */ static int init_suite(void) { return 0; } static int clean_suite(void) { return 0; } static void test_strnpbrk() { char str[] = "ahoj"; CU_ASSERT(strnpbrk(str, 4, "a") == (str + 0)); CU_ASSERT(strnpbrk(str, 4, "h") == (str + 1)); CU_ASSERT(strnpbrk(str, 4, "b") == NULL); CU_ASSERT(strnpbrk(str, 1, "h") == NULL); CU_ASSERT(strnpbrk(str, 4, "xo") == (str + 2)); CU_ASSERT(strnpbrk(str, 4, "j") == (str + 3)); } static void test_Int32ToStr() { const size_t max=32+1; int32_t val[] = {0, 1, -1, INT32_MIN, INT32_MAX, 0x01234567, 0x89abcdef}; int N = sizeof(val) / sizeof(int32_t); int i; char str[max]; char ref[max]; size_t len; // test signed conversion to decimal numbers for (i=0; i