ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=6e34ba51e8f9c6ddc569263630b5f5ed7ae8e077

commit 6e34ba51e8f9c6ddc569263630b5f5ed7ae8e077
Author: Andy Williams <a...@andywilliams.me>
Date:   Sun Apr 12 16:56:17 2015 +0100

    search: Fix issue when text is at end of line
    
    Tests were wrong, fix and add more
---
 elm_code/src/lib/elm_code_text.c        | 2 +-
 elm_code/src/tests/elm_code_test_text.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/elm_code/src/lib/elm_code_text.c b/elm_code/src/lib/elm_code_text.c
index 2a68413..206a6cf 100644
--- a/elm_code/src/lib/elm_code_text.c
+++ b/elm_code/src/lib/elm_code_text.c
@@ -56,7 +56,7 @@ elm_code_line_text_strpos(Elm_Code_Line *line, const char 
*search, int offset)
      return ELM_CODE_TEXT_NOT_FOUND;
 
    ptr += offset;
-   for (c = offset; c < length - strlen(search); c++)
+   for (c = offset; c <= length - searchlen; c++)
      {
         if (!strncmp(ptr, search, searchlen))
           return c;
diff --git a/elm_code/src/tests/elm_code_test_text.c 
b/elm_code/src/tests/elm_code_test_text.c
index 3aad59e..f017835 100644
--- a/elm_code/src/tests/elm_code_test_text.c
+++ b/elm_code/src/tests/elm_code_test_text.c
@@ -46,7 +46,7 @@ START_TEST (elm_code_text_contains_test)
    code = elm_code_create();
    file = elm_code_file_new(code);
 
-   elm_code_file_line_append(file, "a test string...", 17, NULL);
+   elm_code_file_line_append(file, "a test string...", 16, NULL);
    line = elm_code_file_line_get(file, 1);
 
    ck_assert_int_eq(EINA_TRUE, elm_code_line_text_contains(line, "test"));
@@ -66,7 +66,7 @@ START_TEST (elm_code_text_strpos_test)
    code = elm_code_create();
    file = elm_code_file_new(code);
 
-   elm_code_file_line_append(file, "a test string...", 17, NULL);
+   elm_code_file_line_append(file, "a test string...", 16, NULL);
    line = elm_code_file_line_get(file, 1);
 
    ck_assert_int_eq(2, elm_code_line_text_strpos(line, "test", 0));
@@ -76,6 +76,7 @@ START_TEST (elm_code_text_strpos_test)
    ck_assert_int_eq(ELM_CODE_TEXT_NOT_FOUND, elm_code_line_text_strpos(line, 
"text", 0));
 
    ck_assert_int_eq(0, elm_code_line_text_strpos(line, "a t", 0));
+   ck_assert_int_eq(ELM_CODE_TEXT_NOT_FOUND, elm_code_line_text_strpos(line, 
"a t", 2));
    ck_assert_int_eq(13, elm_code_line_text_strpos(line, "...", 0));
 }
 END_TEST

-- 


Reply via email to