mirror of
https://github.com/Green-Sky/crdt_tests.git
synced 2025-06-26 14:16:45 +02:00
bugfixing, debug. still broken, but better
This commit is contained in:
@ -245,11 +245,11 @@ struct TextDocument {
|
||||
//std::cout << "text between: " << getText() << "\n";
|
||||
|
||||
// 2. add range (add all text_start - text_end)
|
||||
if (text_start < text_end) {
|
||||
if (state.doc_size < text.size()) {
|
||||
auto tmp_add_ops = addText(
|
||||
list_start == 0 ? std::nullopt : std::make_optional(state.list[list_start-1].id),
|
||||
list_start == state.list.size() ? std::nullopt :std::make_optional(state.list.at(list_start).id),
|
||||
text.substr(text_start, text_end-text_start)
|
||||
text.substr(text_start, text.size() - state.doc_size)
|
||||
);
|
||||
//std::cout << "added: " << tmp_add_ops.size() << "\n";
|
||||
ops.insert(ops.end(), tmp_add_ops.begin(), tmp_add_ops.end());
|
||||
|
@ -398,8 +398,21 @@ void testChange1(size_t seed) {
|
||||
assert(doc.getText() == otherdoc.getText());
|
||||
}
|
||||
|
||||
void testBugSame(void) {
|
||||
Doc doc;
|
||||
doc.local_agent = 'A';
|
||||
|
||||
std::string_view new_text1{"a"};
|
||||
doc.merge(new_text1);
|
||||
assert(doc.getText() == new_text1);
|
||||
|
||||
std::string_view new_text2{"aa"};
|
||||
doc.merge(new_text2);
|
||||
assert(doc.getText() == new_text2);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
const size_t loops = 10'000;
|
||||
const size_t loops = 1'000;
|
||||
{
|
||||
std::cout << "testEmptyDocAdds:\n";
|
||||
for (size_t i = 0; i < loops; i++) {
|
||||
@ -453,6 +466,13 @@ int main(void) {
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::string(40, '=') << "\n";
|
||||
|
||||
{
|
||||
std::cout << "testBugNLNL:\n";
|
||||
testBugSame();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user