- for(const auto &s: test_case->expected_output)
- if(find(stages, s.first)==stages.end())
- fail(format("Compiler didn't produce stage %s", GL::SL::Stage::get_stage_name(s.first)));
+void GlslCompilerTest::verify_error(const string &output, const string &expected)
+{
+ auto i = output.begin();
+ auto j = expected.begin();
+ bool space = true;
+ while(i!=output.end() && j!=expected.end())
+ {
+ if(*i==*j)
+ {
+ ++i;
+ ++j;
+ }
+ else if(isspace(*i) && isspace(*j))
+ {
+ ++i;
+ ++j;
+ space = true;
+ }
+ else if(space && isspace(*i))
+ ++i;
+ else if(space && isspace(*j))
+ ++j;
+ else
+ {
+ string out_line = extract_line(output, i);
+ string expect_line = extract_line(expected, j);
+ fail(format("Incorrect error line:\n%s\nExpected:\n%s", out_line, expect_line));
+ }
+ }
+
+ while(i!=output.end() && isspace(*i))
+ ++i;
+ while(j!=expected.end() && isspace(*j))
+ ++j;
+
+ if(j!=expected.end())
+ fail(format("Missing error line: %s", extract_line(expected, j)));
+}
+
+string GlslCompilerTest::extract_line(const string &text, const string::const_iterator &iter)
+{
+ string::const_iterator begin = iter;
+ for(; (begin!=text.begin() && *begin!='\n'); --begin) ;
+ if(*begin=='\n')
+ ++begin;
+ string::const_iterator end = iter;
+ for(; (end!=text.end() && *end!='\n'); ++end) ;
+ return string(begin, end);