Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
flow: Add string tests for the ascii backend
Browse files Browse the repository at this point in the history
The current set of tests are all dependent on a build with icu to work.
So, when lacking this dependence, almost all string tests will fail
because of the string format instead of a miss behavior of our ascii
backend.

This patch add the ascii version of those tests so we can exercise the
ascii backend properly (what can be done by compiling soletta without
icu library).

Signed-off-by: Murilo Belluzzo <murilo.belluzzo@intel.com>
  • Loading branch information
mbelluzzo-intel committed Sep 25, 2015
1 parent 0a48771 commit cc34b7e
Show file tree
Hide file tree
Showing 8 changed files with 504 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/test-fbp/string-compare.fbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This file is part of the Soletta Project
#
# Copyright (C) 2015 Intel Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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 COPYRIGHT
# OWNER 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.

full_string(constant/string:value="Hello World")
same_string(constant/string:value="Hello World")
full_upper_string(constant/string:value="HELLO WORLD")
lesser_string(constant/string:value="Hello")
greater_string(constant/string:value="World")

zero(constant/int:value=0)

full_string OUT -> IN[0] cmp_same(string/compare)
same_string OUT -> IN[1] cmp_same EQUAL -> RESULT full_and_same_are_equal(test/result)
cmp_same OUT -> IN[0] cmp_same_is_zero(int/equal)
zero OUT -> IN[1] cmp_same_is_zero OUT -> RESULT full_and_same_gives_zero(test/result)

lesser_string OUT -> IN[0] cmp_less(string/compare)
full_string OUT -> IN[1] cmp_less EQUAL -> IN not_cmp_less(boolean/not)
not_cmp_less OUT -> RESULT lesser_and_full_are_not_equal(test/result)

cmp_less OUT -> IN[0] cmp_less_than_zero(int/less)
zero OUT -> IN[1] cmp_less_than_zero OUT -> RESULT lesser_and_full_gives_less_than_zero(test/result)

greater_string OUT -> IN[0] cmp_great(string/compare)
full_string OUT -> IN[1] cmp_great EQUAL -> IN not_cmp_great(boolean/not)
not_cmp_great OUT -> RESULT greater_and_full_are_not_equal(test/result)

cmp_great OUT -> IN[0] cmp_greater_than_zero(int/greater)
zero OUT -> IN[1] cmp_greater_than_zero OUT -> RESULT greater_and_full_gives_greater_than_zero(test/result)

lesser_string OUT -> IN[0] cmp_bytes(string/compare:bytes=5)
full_string OUT -> IN[1] cmp_bytes EQUAL -> RESULT comparing_n_bytes_equal(test/result)
cmp_bytes OUT -> IN[0] cmp_bytes_is_zero(int/equal)
zero OUT -> IN[1] cmp_bytes_is_zero OUT -> RESULT comparing_n_bytes_gives_zero(test/result)


# regular comparison should fail if case differs
full_string OUT -> IN[0] cmp_case(string/compare)
full_upper_string OUT -> IN[1] cmp_case
cmp_case EQUAL -> IN _(boolean/not) OUT -> RESULT full_and_upper_differs(test/result)

# but should works if ignore_case is set
full_string OUT -> IN[0] cmp_ignore_case(string/compare:ignore_case=true)
full_upper_string OUT -> IN[1] cmp_ignore_case
cmp_ignore_case EQUAL -> RESULT full_and_upper_are_equal_if_ignore_case(test/result)
42 changes: 42 additions & 0 deletions src/test-fbp/string-concat.fbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file is part of the Soletta Project
#
# Copyright (C) 2015 Intel Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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 COPYRIGHT
# OWNER 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.

hello(constant/string:value="Hello")
world(constant/string:value=" World")

hello OUT -> IN[0] concat(string/concatenate)
world OUT -> IN[1] concat
hello_world(constant/string:value="Hello World") OUT -> IN[0] concat_cmp(string/compare)
concat OUT -> IN[1] concat_cmp EQUAL -> RESULT concat_entire_strings(test/result)

hello OUT -> IN[0] concat_n(string/concatenate:bytes=2)
world OUT -> IN[1] concat_n
hello_w(constant/string:value="Hello W") OUT -> IN[0] concat_n_cmp(string/compare)
concat_n OUT -> IN[1] concat_n_cmp EQUAL -> RESULT concat_some_bytes(test/result)
39 changes: 39 additions & 0 deletions src/test-fbp/string-length.fbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is part of the Soletta Project
#
# Copyright (C) 2015 Intel Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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 COPYRIGHT
# OWNER 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.

hello_world(constant/string:value="Hello World")

hello_world OUT -> IN len(string/length)
len OUT -> IN[0] is_len_correct(int/equal)
real_len(constant/int:value=11) OUT -> IN[1] is_len_correct OUT -> RESULT len_works(test/result)

hello_world OUT -> IN len_with_max(string/length:maxlen=5)
len_with_max OUT -> IN[0] is_max(int/equal)
max(constant/int:value=5) OUT -> IN[1] is_max OUT -> RESULT len_with_max_works(test/result)
57 changes: 57 additions & 0 deletions src/test-fbp/string-lower-upper.fbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file is part of the Soletta Project
#
# Copyright (C) 2015 Intel Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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 COPYRIGHT
# OWNER 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.

test_01(constant/string:value="Hello, world")
test_02(constant/string:value="cccCCC")
test_03(constant/string:value="sssSSS")

test_01 OUT -> IN test_01_lower(string/lowercase)
test_01_lower_expected(constant/string:value="hello, world") OUT -> IN[0] test_01_lower_cmp(string/compare)
test_01_lower OUT -> IN[1] test_01_lower_cmp EQUAL -> RESULT _(test/result)

test_01 OUT -> IN test_01_upper(string/uppercase)
test_01_upper_expected(constant/string:value="HELLO, WORLD") OUT -> IN[0] test_01_upper_cmp(string/compare)
test_01_upper OUT -> IN[1] test_01_upper_cmp EQUAL -> RESULT _(test/result)

test_02 OUT -> IN test_02_lower(string/lowercase)
test_02_lower_expected(constant/string:value="cccccc") OUT -> IN[0] test_02_lower_cmp(string/compare)
test_02_lower OUT -> IN[1] test_02_lower_cmp EQUAL -> RESULT _(test/result)

test_02 OUT -> IN test_02_upper(string/uppercase)
test_02_upper_expected(constant/string:value="CCCCCC") OUT -> IN[0] test_02_upper_cmp(string/compare)
test_02_upper OUT -> IN[1] test_02_upper_cmp EQUAL -> RESULT _(test/result)

test_03 OUT -> IN test_03_lower(string/lowercase)
test_03_lower_expected(constant/string:value="ssssss") OUT -> IN[0] test_03_lower_cmp(string/compare)
test_03_lower OUT -> IN[1] test_03_lower_cmp EQUAL -> RESULT _(test/result)

test_03 OUT -> IN test_03_upper(string/uppercase)
test_03_upper_expected(constant/string:value="SSSSSS") OUT -> IN[0] test_03_upper_cmp(string/compare)
test_03_upper OUT -> IN[1] test_03_upper_cmp EQUAL -> RESULT _(test/result)
93 changes: 93 additions & 0 deletions src/test-fbp/string-replace.fbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# This file is part of the Soletta Project
#
# Copyright (C) 2015 Intel Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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 COPYRIGHT
# OWNER 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.

sample_01(constant/string:value="lalal")
out_01(constant/string:value="*al")

sample_01 OUT -> IN replace_01(string/replace:from_string="lal",to_string="*")
replace_01 OUT -> IN[0] cmp_01(string/compare)
out_01 OUT -> IN[1] cmp_01
cmp_01 EQUAL -> RESULT test_01(test/result)

sample_02(constant/string:value="llll")
out_02(constant/string:value="**")

sample_02 OUT -> IN replace_02(string/replace:from_string="ll",to_string="*")
replace_02 OUT -> IN[0] cmp_02(string/compare)
out_02 OUT -> IN[1] cmp_02
cmp_02 EQUAL -> RESULT test_02(test/result)

sample_03(constant/string:value="**")
out_03(constant/string:value="**")

sample_03 OUT -> IN replace_03(string/replace)
replace_03 OUT -> IN[0] cmp_03(string/compare)
out_03 OUT -> IN[1] cmp_03
cmp_03 EQUAL -> RESULT test_03(test/result)

sample_04(constant/string:value="*****")
out_04(constant/string:value="*")

sample_04 OUT -> IN replace_04(string/replace:from_string="**",to_string="")
replace_04 OUT -> IN[0] cmp_04(string/compare)
out_04 OUT -> IN[1] cmp_04
cmp_04 EQUAL -> RESULT test_04(test/result)

sample_05(constant/string:value="")
out_05(constant/string:value="*")

sample_05 OUT -> IN replace_05(string/replace:from_string="",to_string="*")
replace_05 OUT -> IN[0] cmp_05(string/compare)
out_05 OUT -> IN[1] cmp_05
cmp_05 EQUAL -> RESULT test_05(test/result)

sample_06(constant/string:value="** long string ** with stars ** to be changed **")
out_06(constant/string:value="## long string ## with stars #* to be changed **")

sample_06 OUT -> IN replace_06(string/replace:from_string="*",to_string="#",max_replace=5)
replace_06 OUT -> IN[0] cmp_06(string/compare)
out_06 OUT -> IN[1] cmp_06
cmp_06 EQUAL -> RESULT test_06(test/result)

sample_07(constant/string:value="whatever")
out_07(constant/string:value="whatever")

sample_07 OUT -> IN replace_07(string/replace:from_string="no_match",to_string="*")
replace_07 OUT -> IN[0] cmp_07(string/compare)
out_07 OUT -> IN[1] cmp_07
cmp_07 EQUAL -> RESULT test_07(test/result)

sample_08(constant/string:value="whatever")
out_08(constant/string:value="Fail on matching 'no_match' on string whatever")

sample_08 OUT -> IN replace_08(string/replace:from_string="no_match",to_string="*",forward_on_no_match=false)
replace_08 ERROR -> IN _(converter/error) MESSAGE -> IN[0] cmp_08(string/compare)
out_08 OUT -> IN[1] cmp_08
cmp_08 EQUAL -> RESULT result_08(test/result)
73 changes: 73 additions & 0 deletions src/test-fbp/string-slice.fbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This file is part of the Soletta Project
#
# Copyright (C) 2015 Intel Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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 COPYRIGHT
# OWNER 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.

str(constant/string:value="0*2*4*6*8*")

str OUT -> IN slice_01(string/slice:start=0,end=10)
slice_01 OUT -> IN[0] cmp_01(string/compare)
str OUT -> IN[1] cmp_01
cmp_01 EQUAL -> RESULT result_01(test/result)

str OUT -> IN slice_02(string/slice:start=0,end=3)
slice_02 OUT -> IN[0] cmp_02(string/compare)
_(constant/string:value="0*2") OUT -> IN[1] cmp_02
cmp_02 EQUAL -> RESULT result_02(test/result)

str OUT -> IN slice_03(string/slice:start=0,end=-3)
slice_03 OUT -> IN[0] cmp_03(string/compare)
_(constant/string:value="0*2*4*6") OUT -> IN[1] cmp_03
cmp_03 EQUAL -> RESULT result_03(test/result)

str OUT -> IN slice_04(string/slice:start=-7,end=-3)
slice_04 OUT -> IN[0] cmp_04(string/compare)
_(constant/string:value="*4*6") OUT -> IN[1] cmp_04
cmp_04 EQUAL -> RESULT result_04(test/result)

str OUT -> IN slice_05(string/slice:start=-22342,end=10)
slice_05 OUT -> IN[0] cmp_05(string/compare)
str OUT -> IN[1] cmp_05
cmp_05 EQUAL -> RESULT result_05(test/result)

str OUT -> IN slice_06(string/slice:start=0,end=-12)
slice_06 OUT -> IN[0] cmp_06(string/compare)
_(constant/string:value="") OUT -> IN[1] cmp_06
cmp_06 EQUAL -> RESULT result_06(test/result)

str OUT -> IN slice_07(string/slice:start=666,end=888)
slice_07 OUT -> IN[0] cmp_07(string/compare)
_(constant/string:value="") OUT -> IN[1] cmp_07
cmp_07 EQUAL -> RESULT result_07(test/result)

str OUT -> IN slice_08(string/slice:start=0,end=666)
slice_08 OUT -> IN[0] cmp_08(string/compare)
str OUT -> IN[1] cmp_08
cmp_08 EQUAL -> RESULT result_08(test/result)


Loading

0 comments on commit cc34b7e

Please sign in to comment.