Commit 47070f62 authored by LiberIT's avatar LiberIT

wrote, tested and passed addenda_theLetter_toThePhrase and

addenda_theText_toThePhrase
parent 2475ee8b
Pipeline #109651396 passed with stages
in 7 minutes and 7 seconds
......@@ -507,3 +507,27 @@ struct Text text_addenda(struct Text input, struct Text produce) {
produce.length++);
return produce;
}
/** addenda_theText_toThePhrase */
struct Phrase fyakyi_hwuska_dva2ttu(struct Phrase phrase, struct Text text) {
guarantee(phrase.page.plength*LINE_LONG > phrase.begin);
const uint phrase_vacancy = phrase.page.plength*LINE_LONG - phrase.begin;
guarantee(phrase_vacancy >= text.length);
repeat(text.length,
DEBUGPRINT(("%c\n", text.letters[iterator]));
phrase =
addenda_theLetter_toThePhrase(text.letters[iterator], phrase);
);
return phrase;
}
/** addenda_theLetter_toThePhrase(letter, phrase)*/
struct Phrase fyakyi_lyatka_dva2ttu(const struct Phrase phrase, uint16_t letter) {
guarantee(phrase.begin+phrase.length < phrase.page.plength*LINE_LONG);
struct Phrase produce = phrase;
const uint16_t inject_point = phrase.begin + phrase.length;
const uint8_t inject_row = inject_point/LINE_LONG;
const uint8_t inject_column = inject_point % LINE_LONG;
produce.page.lines[inject_row][inject_column] = letter;
produce.length++;
return produce;
}
......@@ -166,4 +166,12 @@ struct Text text_addenda(struct Text input, struct Text produce);
_produce = text_addenda(_string, _produce); \
} while(0)
#define addenda_theText_toThePhrase(text, phrase) \
fyakyi_hwuska_dva2ttu(phrase, text)
struct Phrase fyakyi_hwuska_dva2ttu(struct Phrase, struct Text);
#define addenda_theLetter_toThePhrase(letter, phrase) \
fyakyi_lyatka_dva2ttu(phrase, letter)
struct Phrase fyakyi_lyatka_dva2ttu(struct Phrase, uint16_t);
#endif
......@@ -980,12 +980,13 @@ struct Phrase encode_paragraph_quote(struct Phrase phrase, struct Text text,
// need a "get quote length" kinda thing to know how much text it involves.
struct Text full_quote = find_letter_quote(text);
text_print(text);
//DEBUGPRINT(("%X full_quote.length\n", full_quote.length));
//if (full_quote.length > 0) {
// *text_indexFinger = full_quote.letters+full_quote.length - full_quote.letters;
//// struct Text quote_contents = find_letter_quote_contents(full_quote);
//// text_print(quote_contents);
//}
DEBUGPRINT(("%X full_quote.length\n", full_quote.length));
if (full_quote.length > 0) {
*text_indexFinger = full_quote.letters+full_quote.length - full_quote.letters;
struct Text quote_contents = find_letter_quote_contents(full_quote);
text_print(quote_contents);
phrase = addenda_theText_toThePhrase(quote_contents, phrase);
}
//
//
//DEBUGPRINT(("%X length, phrase.length %X \n", length, phrase.length));
......
......@@ -4166,10 +4166,9 @@ const char *quiz_paragraph_quote_encoding_2() {
return 0;
}
const char *quiz_paragraph_quote_encoding_1() {
NewTextPhrase(input, 10, "hnimgina tyutzrondo lyatkyitksuh "
NewTextPhrase(input, 10, "hnimgina ksaszrondo lyatkyitksuh "
"zi.prih."
"The goal is not to be better than the other man, but your previous self.\n"
"To conquer oneself is a greater victory than to conquer thousands in a battle.\n"
"-- Dalai Lama"
".prih.zi"
"prah");
......@@ -4179,11 +4178,11 @@ const char *quiz_paragraph_quote_encoding_1() {
mu_assert("", input.page.lines[0][2] == name_GRAMMAR);
mu_assert("", input.page.lines[0][3] == nominative_case_GRAMMAR);
mu_assert("", input.page.lines[0][4] == PARAGRAPH_LETTER_QUOTE);
mu_assert("", input.page.lines[0][5] == 0x20);
mu_assert("", input.page.lines[0][5] == 0x40);
mu_assert("", input.page.lines[0][6] == declarative_mood_GRAMMAR);
mu_assert("", input.page.lines[1][0] == 0);
mu_assert("", input.page.lines[2][0] == 0);
mu_assert("", input.page.lines[3][1] == paragraph_GRAMMAR);
mu_assert("", input.page.lines[1][0] == 'T');
mu_assert("", input.page.lines[1][1] == 'h');
mu_assert("", input.page.lines[5][1] == paragraph_GRAMMAR);
DEBUGPRINT(("%X input.length\n", input.length));
mu_assert("", input.length >= 0x31);
NewTextPhrase(compare_phrase, 4, "hnimgina tyutzrondo lyatkyitksuh prah");
......@@ -4224,9 +4223,45 @@ const char *quiz_paragraph_quote_encoding_null() {
text_phrase_print(input);
return 0;
}
const char *quiz_addenda_theLetter_toThePhrase() {
NewPagePhrase(phrase, 1);
phrase.begin = 0;
phrase.length = 0;
struct Phrase produce = addenda_theLetter_toThePhrase('h', phrase);
Page_print(produce.page);
phrase_print(produce);
mu_assert("", produce.page.lines[0][0] == 'h');
mu_assert("", produce.length == 1);
return 0;
}
const char *quiz_addenda_theText_toThePhrase() {
NewText(text, "hello world");
NewPagePhrase(phrase, 1);
struct Phrase produce = addenda_theText_toThePhrase(text, phrase);
text_print(text);
Page_print(produce.page);
phrase_print(produce);
mu_assert("", produce.page.lines[0][0] == 'h');
mu_assert("", produce.page.lines[0][1] == 'e');
mu_assert("", produce.page.lines[0][2] == 'l');
mu_assert("", produce.page.lines[0][3] == 'l');
mu_assert("", produce.page.lines[0][4] == 'o');
mu_assert("", produce.page.lines[0][5] == ' ');
mu_assert("", produce.page.lines[0][6] == 'w');
mu_assert("", produce.page.lines[0][7] == 'o');
mu_assert("", produce.page.lines[0][8] == 'r');
mu_assert("", produce.page.lines[0][9] == 'l');
mu_assert("", produce.page.lines[0][0xA] == 'd');
mu_assert("", produce.page.lines[0][0xB] == 0);
mu_assert("", produce.length = 11);
return 0;
}
const char *quiz_paragraph_quote_encoding() {
mu_run_quiz(quiz_paragraph_quote_encoding_null);
mu_run_quiz(quiz_addenda_theLetter_toThePhrase);
mu_run_quiz(quiz_addenda_theText_toThePhrase);
TODO(mu_assert("#TODO quiz_paragraph_quote_encoding_1", 1==0));
//mu_run_quiz(quiz_paragraph_quote_encoding_1);
// mu_run_quiz(quiz_paragraph_quote_encoding_null);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment