MCPcopy Create free account
hub / github.com/MikeMirzayanov/testlib / StringInputStreamReader

Class StringInputStreamReader

testlib.h:1691–1751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1689}
1690
1691class StringInputStreamReader : public InputStreamReader {
1692private:
1693 std::string s;
1694 size_t pos;
1695
1696public:
1697 StringInputStreamReader(const std::string &content) : s(content), pos(0) {
1698 // No operations.
1699 }
1700
1701 void setTestCase(int) {
1702 __testlib_fail("setTestCase not implemented in StringInputStreamReader");
1703 }
1704
1705 std::vector<int> getReadChars() {
1706 __testlib_fail("getReadChars not implemented in StringInputStreamReader");
1707 }
1708
1709 int curChar() {
1710 if (pos >= s.length())
1711 return EOFC;
1712 else
1713 return s[pos];
1714 }
1715
1716 int nextChar() {
1717 if (pos >= s.length()) {
1718 pos++;
1719 return EOFC;
1720 } else
1721 return s[pos++];
1722 }
1723
1724 void skipChar() {
1725 pos++;
1726 }
1727
1728 void unreadChar(int c) {
1729 if (pos == 0)
1730 __testlib_fail("StringInputStreamReader::unreadChar(int): pos == 0.");
1731 pos--;
1732 if (pos < s.length())
1733 s[pos] = char(c);
1734 }
1735
1736 std::string getName() {
1737 return __testlib_part(s);
1738 }
1739
1740 int getLine() {
1741 return -1;
1742 }
1743
1744 bool eof() {
1745 return pos >= s.length();
1746 }
1747
1748 void close() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected