BLOCK_SIZE1 = 128 BLOCK_SIZE2 = 8 str_list1 = [b'foo', b'bar', b'', b' '] str_list2 = [b'foo', b'', b'x', b' '] str_nloops = len(str_list1) * (BLOCK_SIZE1 + BLOCK_SIZE2 + 1) str_array1 = array(str_list1 * str_nloops) str_array2 = array(str_list2 * str_nloops) str_co
| 444 | ''' |
| 445 | |
| 446 | class test_strings(unittest.TestCase): |
| 447 | # NE3 strings and unicode support not implemented yet |
| 448 | ''' |
| 449 | BLOCK_SIZE1 = 128 |
| 450 | BLOCK_SIZE2 = 8 |
| 451 | str_list1 = [b'foo', b'bar', b'', b' '] |
| 452 | str_list2 = [b'foo', b'', b'x', b' '] |
| 453 | str_nloops = len(str_list1) * (BLOCK_SIZE1 + BLOCK_SIZE2 + 1) |
| 454 | str_array1 = array(str_list1 * str_nloops) |
| 455 | str_array2 = array(str_list2 * str_nloops) |
| 456 | str_constant = b'doodoo' |
| 457 | |
| 458 | def test_null_chars(self): |
| 459 | str_list = [ |
| 460 | b'\0\0\0', b'\0\0foo\0', b'\0\0foo\0b', b'\0\0foo\0b\0', |
| 461 | b'foo\0', b'foo\0b', b'foo\0b\0', b'foo\0bar\0baz\0\0'] |
| 462 | for s in str_list: |
| 463 | r = evaluate('s') |
| 464 | self.assertEqual(s, r.tostring()) # check *all* stored data |
| 465 | |
| 466 | def test_compare_copy(self): |
| 467 | sarr = self.str_array1 |
| 468 | expr = 'sarr' |
| 469 | res1 = eval(expr) |
| 470 | res2 = evaluate(expr) |
| 471 | assert_array_equal(res1, res2) |
| 472 | |
| 473 | def test_compare_array(self): |
| 474 | sarr1 = self.str_array1 |
| 475 | sarr2 = self.str_array2 |
| 476 | expr = 'sarr1 >= sarr2' |
| 477 | res1 = eval(expr) |
| 478 | res2 = evaluate(expr) |
| 479 | assert_array_equal(res1, res2) |
| 480 | |
| 481 | def test_compare_variable(self): |
| 482 | sarr = self.str_array1 |
| 483 | svar = self.str_constant |
| 484 | expr = 'sarr >= svar' |
| 485 | res1 = eval(expr) |
| 486 | res2 = evaluate(expr) |
| 487 | assert_array_equal(res1, res2) |
| 488 | |
| 489 | def test_compare_constant(self): |
| 490 | sarr = self.str_array1 |
| 491 | expr = 'sarr >= %r' % self.str_constant |
| 492 | res1 = eval(expr) |
| 493 | res2 = evaluate(expr) |
| 494 | assert_array_equal(res1, res2) |
| 495 | |
| 496 | def test_add_string_array(self): |
| 497 | sarr1 = self.str_array1 |
| 498 | sarr2 = self.str_array2 |
| 499 | expr = 'sarr1 + sarr2' |
| 500 | self.assert_missing_op('add_sss', expr, locals()) |
| 501 | |
| 502 | def test_empty_string1(self): |
| 503 | a = np.array(['', 'pepe']) |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…