aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/unit/testRunStyles.cxx
diff options
context:
space:
mode:
authornyamatongwe <unknown>2013-04-15 20:10:51 +1000
committernyamatongwe <unknown>2013-04-15 20:10:51 +1000
commit11173e2c5c822283e53af1713a42b348f2e504e0 (patch)
tree95a829aa5d9187f6d2369413c7061ddd793fedd0 /test/unit/testRunStyles.cxx
parent7d362c38ef421be1d6003b5a2a1bfc560c50b313 (diff)
downloadscintilla-mirror-11173e2c5c822283e53af1713a42b348f2e504e0.tar.gz
RunStyles can be corrupted by filling 0 length ranges and ranges that go past end
so throw std::invalid_argument exceptions for these conditions. Provide a Check method to validate the consistency of a RunStyles and throw std::runtime_error if corruption is detected.
Diffstat (limited to 'test/unit/testRunStyles.cxx')
-rw-r--r--test/unit/testRunStyles.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/unit/testRunStyles.cxx b/test/unit/testRunStyles.cxx
index 8fec25b56..3c09dd87a 100644
--- a/test/unit/testRunStyles.cxx
+++ b/test/unit/testRunStyles.cxx
@@ -2,6 +2,8 @@
#include <string.h>
+#include <stdexcept>
+
#include "Platform.h"
#include "SplitVector.h"
@@ -311,4 +313,20 @@ TEST_F(RunStylesTest, DeleteEndRun) {
EXPECT_EQ(1, prs->EndRun(0));
EXPECT_EQ(0, prs->StartRun(1));
EXPECT_EQ(1, prs->EndRun(1));
+ prs->Check();
+}
+
+TEST_F(RunStylesTest, OutsideBounds) {
+ prs->InsertSpace(0, 1);
+ int startFill = 1;
+ int lengthFill = 1;
+ try {
+ prs->FillRange(startFill, 99, lengthFill);
+ } catch (std::invalid_argument &) {
+ // Exception is supposed to occur so ignore.
+ }
+ EXPECT_EQ(1, prs->Length());
+ EXPECT_EQ(1, prs->Runs());
+ EXPECT_EQ(0, prs->StartRun(0));
+ EXPECT_EQ(1, prs->EndRun(0));
}