diff options
author | nyamatongwe <devnull@localhost> | 2013-04-15 20:10:51 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2013-04-15 20:10:51 +1000 |
commit | 7d7d3d61d6c663aa1a416027ef9a7fc98559ccb0 (patch) | |
tree | c8fd5302c502f4b90cf25906b4cca246e36ab540 /test/unit/testRunStyles.cxx | |
parent | afaccacc703e9e436d2bc1c0a8900b8d8c0c7f65 (diff) | |
download | scintilla-mirror-7d7d3d61d6c663aa1a416027ef9a7fc98559ccb0.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.cxx | 18 |
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)); } |