ut_string.c

00001 /*
00002 # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall.
00003 #
00004 # This file is part of the Python-on-a-Chip program.
00005 # Python-on-a-Chip is free software: you can redistribute it and/or modify
00006 # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
00007 #
00008 # Python-on-a-Chip is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011 # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
00012 # is seen in the file COPYING up one directory from this.
00013 */
00014 
00015 
00022 #include "CuTest.h"
00023 #include "pm.h"
00024 
00025 
00031 void
00032 ut_string_new_000(CuTest *tc)
00033 {
00034     pPmObj_t pstring;
00035     uint8_t cstring[] = "forty-two";
00036     uint8_t const *pcstring = cstring;
00037     PmReturn_t retval;
00038 
00039     pm_init(MEMSPACE_RAM, C_NULL);
00040 
00041     /* Check the return value is Ok */
00042     retval = string_new(&pcstring, &pstring);
00043     CuAssertTrue(tc, retval == PM_RET_OK);
00044     CuAssertTrue(tc, ((pPmString_t)pstring)->length == 9);
00045 }
00046 
00047 
00053 void
00054 ut_string_newFromChar_000(CuTest *tc)
00055 {
00056     pPmObj_t pstring;
00057     uint8_t cchar = 'Z';
00058     PmReturn_t retval;
00059 
00060     pm_init(MEMSPACE_RAM, C_NULL);
00061 
00062     /* Check the return value is Ok */
00063     retval = string_newFromChar(cchar, &pstring);
00064     CuAssertTrue(tc, retval == PM_RET_OK);
00065     CuAssertTrue(tc, ((pPmString_t)pstring)->length == 1);
00066 }
00067 
00068 
00070 CuSuite *getSuite_testStringObj(void)
00071 {
00072     CuSuite* suite = CuSuiteNew();
00073 
00074     SUITE_ADD_TEST(suite, ut_string_new_000);
00075     SUITE_ADD_TEST(suite, ut_string_newFromChar_000);
00076 
00077     return suite;
00078 }

Generated on Mon Oct 18 07:40:47 2010 for Python-on-a-chip by  doxygen 1.5.9