20#include <boost/test/unit_test.hpp>
22#include <wx/clipbrd.h>
25#include <wx/filename.h>
26#include <wx/mstream.h>
33 std::string testText =
"Basic clipboard test";
46 std::string emptyText =
"";
58 std::string utf8Text =
"Héllo Wörld! 你好 🚀";
70 std::string largeText( 10000,
'A' );
83 std::string specialText =
"Line1\nLine2\tTabbed\r\nWindows newline";
96 if( wxTheClipboard->Open() )
98 wxTheClipboard->Clear();
99 wxTheClipboard->Close();
103 BOOST_CHECK( result.empty() );
117 std::vector<std::vector<wxString>> testData = {
118 { wxS(
"A1"), wxS(
"B1"), wxS(
"C1") },
119 { wxS(
"A2"), wxS(
"B2"), wxS(
"C2") },
120 { wxS(
"A3"), wxS(
"B3"), wxS(
"C3") }
127 std::vector<std::vector<wxString>> retrieved;
133 for(
size_t i = 0; i < testData.size() && i < retrieved.size(); ++i )
136 for(
size_t j = 0; j < testData[i].size() && j < retrieved[i].size(); ++j )
147 std::vector<std::vector<wxString>> emptyData;
152 std::vector<std::vector<wxString>> retrieved;
157 BOOST_CHECK( retrieved.empty() );
164 std::vector<std::vector<wxString>> singleCell = {
172 std::vector<std::vector<wxString>> retrieved;
186 std::vector<std::vector<wxString>> dataWithCommas = {
187 { wxS(
"Value, with comma"), wxS(
"Normal") },
188 { wxS(
"Another, comma"), wxS(
"Also normal") }
195 std::vector<std::vector<wxString>> retrieved;
201 for(
size_t i = 0; i < dataWithCommas.size() && i < retrieved.size(); ++i )
204 for(
size_t j = 0; j < dataWithCommas[i].size() && j < retrieved[i].size(); ++j )
215 std::vector<std::vector<wxString>> dataWithQuotes = {
216 { wxS(
"\"Quoted value\""), wxS(
"Normal") },
217 { wxS(
"Value with \"inner\" quotes"), wxS(
"Plain") }
224 std::vector<std::vector<wxString>> retrieved;
237 std::vector<std::vector<wxString>> dataWithNewlines = {
238 { wxS(
"Line1\nLine2"), wxS(
"Normal") },
239 { wxS(
"Single line"), wxS(
"Another\nmultiline") }
246 std::vector<std::vector<wxString>> retrieved;
259 std::vector<std::vector<wxString>> irregularData = {
260 { wxS(
"A1"), wxS(
"B1"), wxS(
"C1"), wxS(
"D1") },
261 { wxS(
"A2"), wxS(
"B2") },
262 { wxS(
"A3"), wxS(
"B3"), wxS(
"C3") }
269 std::vector<std::vector<wxString>> retrieved;
276 for(
size_t i = 0; i < irregularData.size() && i < retrieved.size(); ++i )
278 for(
size_t j = 0; j < irregularData[i].size() && j < retrieved[i].size(); ++j )
290 std::string invalidText =
"This is not tabular data\nJust some text";
293 std::vector<std::vector<wxString>> retrieved;
304 if( wxTheClipboard->Open() )
306 wxTheClipboard->Clear();
307 wxTheClipboard->Close();
326 std::vector<std::string> testStrings = {
328 "Second string with 特殊字符",
329 "Third string\nwith\nnewlines",
333 for(
const auto& testString : testStrings )
347 std::string testText1 =
"Concurrent test 1";
348 std::string testText2 =
"Concurrent test 2";
363 std::string persistentText =
"This should persist after flush";
bool SaveTabularDataToClipboard(const std::vector< std::vector< wxString > > &aData)
Store tabular data to the system clipboard.
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
std::unique_ptr< wxImage > GetImageFromClipboard()
Get image data from the clipboard, if there is any.
bool GetTabularDataFromClipboard(std::vector< std::vector< wxString > > &aData)
Attempt to get tabular data from the clipboard.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_AUTO_TEST_CASE(SaveClipboard_BasicText)
BOOST_AUTO_TEST_SUITE_END()