OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } grammarErrors[] = { | 58 } grammarErrors[] = { |
59 {"I have a issue.", 7, 1}, | 59 {"I have a issue.", 7, 1}, |
60 {"I have an grape.", 7, 2}, | 60 {"I have an grape.", 7, 2}, |
61 {"I have an kiwi.", 7, 2}, | 61 {"I have an kiwi.", 7, 2}, |
62 {"I have an muscat.", 7, 2}, | 62 {"I have an muscat.", 7, 2}, |
63 {"You has the right.", 4, 3}, | 63 {"You has the right.", 4, 3}, |
64 {"apple orange zz.", 0, 16}, | 64 {"apple orange zz.", 0, 16}, |
65 {"apple zz orange.", 0, 16}, | 65 {"apple zz orange.", 0, 16}, |
66 {"apple,zz,orange.", 0, 16}, | 66 {"apple,zz,orange.", 0, 16}, |
67 {"orange,zz,apple.", 0, 16}, | 67 {"orange,zz,apple.", 0, 16}, |
68 {"the the adlj adaasj sdklj. there there", 0, 38}, | 68 {"the the adlj adaasj sdklj. there there", 4, 3}, |
| 69 {"the the adlj adaasj sdklj. there there", 33, 5}, |
69 {"zz apple orange.", 0, 16}, | 70 {"zz apple orange.", 0, 16}, |
70 }; | 71 }; |
71 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(grammarErrors); ++i) { | 72 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(grammarErrors); ++i) { |
72 size_t offset = 0; | 73 size_t offset = 0; |
73 string16 error(grammarErrors[i].text, grammarErrors[i].text + strlen(gra
mmarErrors[i].text)); | 74 string16 error(grammarErrors[i].text, grammarErrors[i].text + strlen(gra
mmarErrors[i].text)); |
74 while ((offset = stringText.find(error, offset)) != string16::npos) { | 75 while ((offset = stringText.find(error, offset)) != string16::npos) { |
75 results->push_back(WebTextCheckingResult(WebTextDecorationTypeGramma
r, offset + grammarErrors[i].location, grammarErrors[i].length)); | 76 results->push_back(WebTextCheckingResult(WebTextDecorationTypeGramma
r, offset + grammarErrors[i].location, grammarErrors[i].length)); |
76 offset += grammarErrors[i].length; | 77 offset += grammarErrors[i].length; |
77 } | 78 } |
78 } | 79 } |
79 return false; | 80 return false; |
80 } | 81 } |
81 | 82 |
82 } | 83 } |
OLD | NEW |