0.3.0 LineFormatter

This commit is contained in:
Rob Tillaart 2024-02-19 20:13:19 +01:00
parent 062d7f2d43
commit c8ec50f78e
20 changed files with 487 additions and 103 deletions

View File

@ -6,10 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.3.0] - 2024-02-19
- add **bool setTabs(uint8_t \* arr, uint8_t size)** to add multiple tabs in one call.
- add **uint8_t getTabs(uint8_t \* arr)** get the internal array in one call. Returns size.
- update readme.md
- update examples
- minor edits.
----
## [0.2.1] - 2023-11-07
- update readme.md
## [0.2.0] - 2023-01-30
- add **removeTab(pos)**
- add **existTab(pos)** (prevent double addition).

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020-2023 Rob Tillaart
Copyright (c) 2020-2024 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,7 +1,7 @@
//
// FILE: LineFormatter.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.1
// VERSION: 0.3.0
// PURPOSE: Simple positioning wrapper class for Serial
// DATE: 2020-05-14
// URL: https://github.com/RobTillaart/LineFormatter
@ -32,10 +32,10 @@ void LineFormatter::reset()
//
// WRITE - the core
//
size_t LineFormatter::write(uint8_t c)
size_t LineFormatter::write(uint8_t ch)
{
// handle tabs.
if (_tabCount && (c == '\t'))
if (_tabCount && (ch == '\t'))
{
write(' ');
for (int i = 0; i < _tabCount; i++)
@ -49,12 +49,12 @@ size_t LineFormatter::write(uint8_t c)
}
else
{
_stream->write(c);
_stream->write(ch);
_pos++;
}
// handle return
if (c == '\n')
if (ch == '\n')
{
_pos = 0;
_lineCount++;
@ -89,9 +89,9 @@ uint8_t LineFormatter::getMaxLength()
}
uint8_t LineFormatter::gotoPos(uint8_t pos)
uint8_t LineFormatter::gotoPos(uint8_t position)
{
while (_pos < pos) write(' ');
while (_pos < position) write(' ');
return _pos;
}
@ -100,9 +100,9 @@ uint8_t LineFormatter::gotoPos(uint8_t pos)
//
// REPEAT
//
void LineFormatter::repeat(uint8_t n, char c, uint8_t newLine)
void LineFormatter::repeat(uint8_t n, char ch, uint8_t newLine)
{
while (n--) print(c);
while (n--) print(ch);
while (newLine--) write('\n');
}
@ -135,15 +135,38 @@ uint8_t LineFormatter::getAutoNewLine()
//
// TAB
//
bool LineFormatter::addTab(uint8_t pos)
bool LineFormatter::setTabs(uint8_t * positions, uint8_t size)
{
if (pos == 0) return false;
if (size >= MAX_TAB_STOPS) return false;
for (uint8_t i = 0; i < MAX_TAB_STOPS; i++)
{
if (i >= size) _tabStop[i] = 0;
else _tabStop[i] = positions[i];
}
_tabCount = size;
return true;
}
uint8_t LineFormatter::getTabs(uint8_t * positions)
{
for (uint8_t i = 0; i < _tabCount; i++)
{
positions[i] = _tabStop[i];
}
return _tabCount;
}
bool LineFormatter::addTab(uint8_t position)
{
if (position == 0) return false;
// full ?
if (_tabCount >= MAX_TAB_STOPS) return false;
// prevent doubles.
if (existTab(pos)) return false;
if (existTab(position)) return false;
_tabStop[_tabCount] = pos;
_tabStop[_tabCount] = position;
_tabCount++;
return true;
}
@ -169,11 +192,11 @@ void LineFormatter::clearTabs()
};
bool LineFormatter::removeTab(uint8_t pos)
bool LineFormatter::removeTab(uint8_t position)
{
for (uint8_t i = 0; i < _tabCount; i++)
{
if (_tabStop[i] == pos)
if (_tabStop[i] == position)
{
_tabCount--;
while(i < _tabCount)
@ -188,11 +211,11 @@ bool LineFormatter::removeTab(uint8_t pos)
}
bool LineFormatter::existTab(uint8_t pos)
bool LineFormatter::existTab(uint8_t position)
{
for (uint8_t i = 0; i < _tabCount; i++)
{
if (_tabStop[i] == pos) return true;
if (_tabStop[i] == position) return true;
}
return false;
}
@ -246,15 +269,15 @@ void LineFormatter::printRuler(uint8_t length)
uint8_t t = 0;
for (uint8_t i = 1; i <= length; i++)
{
char c = '.';
char ch = '.';
if (i == _tabStop[t])
{
c = '#';
ch = '#';
t++;
}
else if ((i % 10) == 0) c = '0';
else if ((i % 5) == 0) c = '5';
write(c);
else if ((i % 10) == 0) ch = '0';
else if ((i % 5) == 0) ch = '5';
write(ch);
}
write('\n');
}

View File

@ -2,7 +2,7 @@
//
// FILE: LineFormatter.h
// AUTHOR: Rob Tillaart
// VERSION: 0.2.1
// VERSION: 0.3.0
// PURPOSE: Simple positioning wrapper class for Serial / Stream
// DATE: 2020-05-14
// URL: https://github.com/RobTillaart/LineFormatter
@ -15,7 +15,7 @@
#define MAX_TAB_STOPS 12
#endif
#define LINEFORMATTER_LIB_VERSION (F("0.2.1"))
#define LINEFORMATTER_LIB_VERSION (F("0.3.0"))
class LineFormatter: public Print
@ -25,7 +25,7 @@ public:
void reset();
size_t write(uint8_t c);
size_t write(uint8_t ch);
// set the maximum line length - bold cut off
@ -34,12 +34,12 @@ public:
// if position is smaller than n, move to the right
uint8_t gotoPos(uint8_t pos);
uint8_t gotoPos(uint8_t position);
// repeat a char or a "string" n times
// followed by 0 or more newlines.
void repeat(uint8_t n, char c, uint8_t newLine = 0);
void repeat(uint8_t n, char ch, uint8_t newLine = 0);
void repeat(uint8_t n, const char* str, uint8_t newLine = 0);
@ -48,16 +48,22 @@ public:
uint8_t getAutoNewLine();
// Add a tab at (absolute/relative) position
// Set the internal array of tabs at once, easy bulk config,
// positions is an increasing array.
bool setTabs(uint8_t * positions, uint8_t size);
// get array with positions.
uint8_t getTabs(uint8_t * positions);
// Add one tab at (absolute or relative) position
// returns true on success
bool addTab(uint8_t pos);
bool addTab(uint8_t position);
bool addRelTab(uint8_t n);
// remove all the tabs,
void clearTabs();
// remove tab at position pos
// remove tab at position position
// returns false if it does not exist.
bool removeTab(uint8_t pos);
bool existTab(uint8_t pos);
bool removeTab(uint8_t position);
bool existTab(uint8_t position);
// print zero or more tabs, similar as e.g. "\t\t\t"
// optimized repeat

View File

@ -20,8 +20,9 @@ LineFormatter is a wrapper class for Serial (and other streams) to enhance
layout of tabular data.
The class intercepts the **TAB (\t)** characters printed and replaces them with spaces to
the next defined tab-position. These positions can be created with **addTab(pos)**
the next defined tab-position. These positions can be created with **addTab(position)**
for absolute positions and **addRelTab(n)** for relative positions.
Since 0.3.0 one can set all tab positions with **setTabs(arr, size)**.
Absolute tab positions must be added in **increasing** order as the class does not
check or sort the input. Adding the same tab position is not possible since 0.2.0.
@ -31,14 +32,14 @@ The maximum number of tabs is defined by **MAX_TAB_STOPS** == 12 default.
This value can be overruled by -D compile flag or edited in the LineFormatter.h file.
All tab positions can be cleared in one call by **clearTabs()**.
Since 0.2.0 the library also supports **removeTab(pos)** to remove a single tab.
Since 0.2.0 the library also supports **removeTab(position)** to remove a single tab.
The function **autoNewLine(n)** prints a newline after every n lines automatically.
This makes it easier to count the lines in a table, e.g after every 10 lines.
Setting **n** to 0 disables this function.
The function **gotoPos(pos)** prints spaces until the cursor is on position **pos**.
If the current position is beyond **pos**, it does nothing (check the returned position!).
The function **gotoPos(position)** prints spaces until the cursor is on position **position**.
If the current position is beyond **position**, it does nothing (check the returned position!).
Besides for tabular data, this function can be used to make simple text based
graphs, e.g. a sine wave.
@ -59,6 +60,8 @@ A 16 bit lineFormatter is planned for future (on request).
#### Related
- https://github.com/RobTillaart/ANSI
- https://github.com/RobTillaart/PrintSize helper for right alignment
- https://github.com/RobTillaart/printHelpers formatters
## Interface
@ -76,41 +79,71 @@ Connects to a stream, default Serial.
#### Printing
- **size_t write(uint8_t c)** implements printing per character.
- **uint8_t gotoPos(uint8_t pos)** if position is smaller than pos, move to the right.
- **size_t write(uint8_t ch)** implements printing per character.
- **uint8_t gotoPos(uint8_t position)** if position is smaller than position, move to the right.
Returns the updated position.
- **void repeat(uint8_t n, char c, uint8_t newLine = 0)** repeat a char n times.
- **void repeat(uint8_t n, char ch, uint8_t newLine = 0)** repeat a char n times.
Typical used to create separation lines, or multiple line feeds.
The repeated string is optionally followed by a number of newlines.
- **void repeat(uint8_t n, const char\* str, uint8_t newLine = 0)** repeat a "string" n times.
The repeated string is optionally followed by a number of newlines.
Typical used to create separation lines.
- **void tab(uint8_t n = 1)** print zero or more tabs, similar as e.g. "\t\t\t".
As the library implements the **Print** interface, all data types can be printed.
```cpp
LF.print(3.1425);
```
#### Tab configuration
- **bool addTab(uint8_t n)** Add a tab at an absolute position.
- **bool addTab(uint8_t n)** Add a tab at an **absolute** position.
Returns true on success.
Note: no tab can be set on position 0 (return false)
Note: existing tabs will be ignored (return false)
- **bool addRelTab(uint8_t n)** Add a tab at a relative position.
- **bool addRelTab(uint8_t n)** Add a tab at a **relative** position to the last
position in the internal array.
Often this is easier to setup the positions, (think column width).
Returns true on success.
- **void clearTabs()** remove all the tabs.
- **bool removeTab(uint8_t pos)** remove a tab at given position.
Returns true if a tab exists at the position **pos**.
Returns false if no tab existed.
- **void tab(uint8_t n = 1)** print zero or more tabs, similar as e.g. "\t\t\t".
- **bool removeTab(uint8_t position)** remove a tab at given position.
Returns true if a tab exists at **position**.
Returns false if no tab existed at that index.
- **bool setTabs(uint8_t \* positions, uint8_t size)** Set the internal array
of tabs in one call. Clears all existing tabs.
If **size < MAX_TAB_STOPS** the user might add additional tabs with **addTab()**
or with **addRelTab()** and remove with **removeTab()**
- **uint8_t getTabs(uint8_t \* positions)** get the positions stored in the
internal array of tabs. Returns the amount of tab stops.
User must take care that the positions array is large enough.
Typical use is to be able to adjust positions outside this library.
After that the new array can be used as parameter in **setTabs()**.
Note:
Removing a tab is non-reversible (for now), so one cannot insert a removed tab stop again.
Also replacing a tab can only be done by clear all the tabs and reinsert the new ones.
Removing a tab is in essence non-reversible, so one cannot insert a removed tab stop again.
By calling **size = getTabs(arr)** before the removal and call **setTabs(arr, size)** after
the remove one can "restore" the tab.
Replacing a tab can be done with **getTabs()** and **setTabs()** too.
```cpp
// shift all tab positions 4 places to the right.
size = getTabs(arr);
for (int i = 0; i < size; i++) arr[i] += 4;
setTabs(arr, size);
```
#### Line configuration
- **void setMaxLength(uint8_t maxPos)** set the maximum line length - bold cut off.
Will be disabled when set to 0.
Note: maximum line length == 255.
Note: maximum line length == 255 (uint8_t range)
- **uint8_t getMaxLength()** return max line length set.
- **void setAutoNewLine(uint8_t n = 1)** n = 0 switches autoNewLine off.
- **uint8_t getAutoNewLine()** returns number of newlines set before.
@ -127,7 +160,7 @@ For debugging and other purposes there are the following functions:
- **uint8_t getTabStop(uint8_t n)** returns the position of the n-th tab.
- **void printRuler(uint8_t length)** prints a dotted line with 5 and 10 markers,
and # for tab positions.
Line is length long.
The ruler is length long.
## Future
@ -138,18 +171,18 @@ Line is length long.
#### Should
- add sorting to **addTab()** 0.3.0?
- insert sort - bit like in removeTab()
- would allow dynamic inserting.
- add examples
- DS18B20 demo - 6 readings per line, followed by average?
- investigate correct working of maxPosition handling.
- investigate position 1 as tabStop?
- 0 is ignored but 1 is ambiguous
#### Could
- 0.3.0 ?
- add sorting to **addTab()** 0.X.0?
- insert sort - bit like in removeTab()
- would allow dynamic inserting.
- add examples
- DS18B20 demo - 6 readings per line, followed by average?
- 0.X.0 ?
- addTab ==> addAbsoluteTab()
- addRelTab ==> addRelativeTab()
- error handling in addTab()?

View File

@ -2,21 +2,20 @@
// FILE: LineFormatter_Ethernet.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo LineFormatter for EthernetClient
// DATE: 2020-05-23
// URL: https://github.com/RobTillaart/LineFormatter
#include <LineFormatter.h>
#include "LineFormatter.h"
#include <SPI.h>
#include <Ethernet.h>
#include "SPI.h"
#include "Ethernet.h"
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip( 192, 168, 1, 177);
const int EthernetPIN = 10;
EthernetServer server(80); // change to your config
EthernetServer server(80); // change to your configuration
char httpRequest[40];
uint8_t reqCnt;
@ -46,9 +45,12 @@ void HTTP_header(EthernetClient* cl, const char *contentType, bool keepAlive = f
//
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println(__FILE__);
Serial.print("LINEFORMATTER_LIB_VERSION: ");
Serial.println(LINEFORMATTER_LIB_VERSION);
Serial.println();
// Ethernet.init(pin) to configure the CS pin
Ethernet.init(EthernetPIN);
@ -295,4 +297,3 @@ void test_table_2(LineFormatter L)
// -- END OF FILE --

View File

@ -2,12 +2,11 @@
// FILE: LineFormatter_SDcard.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo LineFormatter for SDcard
// DATE: 2020-05-23
// URL: https://github.com/RobTillaart/LineFormatter
#include <SPI.h>
#include <SD.h>
#include "SPI.h"
#include "SD.h"
// SPI PINS UNO
// MOSI 11
@ -17,13 +16,17 @@
#define CS 10 // adjust this ChipSelect line if needed !
#include <LineFormatter.h>
#include "LineFormatter.h"
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println(__FILE__);
Serial.print("LINEFORMATTER_LIB_VERSION: ");
Serial.println(LINEFORMATTER_LIB_VERSION);
Serial.println();
// initialize the SD card
if (!SD.begin(CS))
@ -120,4 +123,3 @@ void test_table(LineFormatter L)
// -- END OF FILE --

View File

@ -14,7 +14,11 @@ int x;
void setup()
{
Serial.begin(115200);
L.println();
L.println(__FILE__);
L.print("LINEFORMATTER_LIB_VERSION: ");
L.println(LINEFORMATTER_LIB_VERSION);
L.repeat(3, '\n');
L.addTab(10);
L.addTab(35);

View File

@ -0,0 +1,30 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560
# - rpipico
libraries:
- "Ethernet"
- "SD"

View File

@ -0,0 +1,84 @@
//
// FILE: LineFormatter_test_getTabs.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo LineFormatter class
// URL: https://github.com/RobTillaart/LineFormatter
#include "LineFormatter.h"
LineFormatter L;
void setup()
{
Serial.begin(115200);
L.println();
L.println(__FILE__);
L.print("LINEFORMATTER_LIB_VERSION: ");
L.println(LINEFORMATTER_LIB_VERSION);
L.repeat(3, '\n');
uint8_t myTabs[10] = {8, 16, 24, 32, 40, 48, 56, 64, 72, 80};
L.setTabs(myTabs, 10);
print_table();
int size = L.getTabs(myTabs);
L.println();
L.print("shift 4 places to right");
L.println();
for (int i = 0; i < size; i++) myTabs[i] += 4;
L.setTabs(myTabs, 10);
print_table();
L.println("Done...");
}
void loop()
{
}
void print_table()
{
// HEADER
L.println("\tIdx\tTime\tValue\tA0\tA1\tA2\tA3\tA4\tA5");
L.repeat(10, "----+----|", 1);
// add empty line every 5 lines
L.setAutoNewLine(5);
// DUMP THE DATA
int measurement = 1;
for (int i = 0; i < 10; i++)
{
L.tab();
L.print(measurement++);
L.tab();
L.print(millis());
L.tab();
L.print(random(12345));
L.tab();
L.print(analogRead(A0));
L.tab();
L.print(analogRead(A1));
L.tab();
L.print(analogRead(A2));
L.tab();
L.print(analogRead(A3));
L.tab();
L.print(analogRead(A4));
L.tab();
L.print(analogRead(A5));
L.println();
delay(random(100));
}
L.setAutoNewLine(0);
L.repeat(2, '\n');
}
// -- END OF FILE --

View File

@ -13,11 +13,14 @@ LineFormatter L;
void setup()
{
Serial.begin(115200);
L.println(__FILE__);
L.println();
L.println(__FILE__);
L.print("LINEFORMATTER_LIB_VERSION: ");
L.println(LINEFORMATTER_LIB_VERSION);
L.repeat(2, '\n');
L.println("Make a simple tabular output");
L.repeat(3, "\n"); // 3 newlines
L.repeat(2, "\n"); // 3 newlines
test_repeat();
test_graph();

View File

@ -13,10 +13,12 @@ LineFormatter L;
void setup()
{
Serial.begin(115200);
L.println();
L.println(__FILE__);
L.print("LINEFORMATTER_LIB_VERSION: ");
L.println(LINEFORMATTER_LIB_VERSION);
L.repeat(2, '\n');
L.repeat(3, '\n');
L.printRuler(80);
for (int i = 0; i < 5; i++)

View File

@ -0,0 +1,30 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560
# - rpipico
libraries:
- "Ethernet"
- "SD"

View File

@ -0,0 +1,112 @@
//
// FILE: LineFormatter_test_setTabs.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo LineFormatter class
// URL: https://github.com/RobTillaart/LineFormatter
#include "LineFormatter.h"
LineFormatter L;
void setup()
{
Serial.begin(115200);
L.println();
L.println(__FILE__);
L.print("LINEFORMATTER_LIB_VERSION: ");
L.println(LINEFORMATTER_LIB_VERSION);
L.repeat(3, '\n');
test_table_1();
test_ruler();
L.clearTabs();
L.addTab(15);
L.print("LineCount:\t");
L.println(L.getLineCount());
L.print("TabCount:\t");
L.println(L.getTabCount());
L.repeat(2, '\n');
L.println("Done...");
}
void loop()
{
}
void test_ruler()
{
L.println();
L.println(__FUNCTION__);
L.repeat(strlen(__FUNCTION__), "=", 2);
uint8_t myTabs[9] = {3, 10, 12, 30, 36, 42, 52, 58, 64};
L.setTabs(myTabs, 9);
L.printRuler(100);
L.clearTabs();
L.printRuler(100);
L.repeat(3, '\n');
}
void test_table_1()
{
L.println();
L.println(__FUNCTION__);
L.repeat(strlen(__FUNCTION__), "=", 2);
// SET TABS ALL AT ONCE
uint8_t myTabs[9] = {3, 10, 20, 30, 36, 42, 52, 58, 64};
L.setTabs(myTabs, 9);
// HEADER
L.println("\tIdx\tTime\tValue\tA0\tA1\tA2\tA3\tA4\tA5");
L.repeat(8, "----+----|", 1);
// add empty line every 5 lines
L.setAutoNewLine(5);
// DUMP THE DATA
int measurement = 1;
for (int i = 0; i < 20; i++)
{
if (i == 10)
{
L.println("switch to normal tab behaviour");
L.clearTabs(); // just to show diff
}
L.tab();
L.print(measurement++);
L.tab();
L.print(millis());
L.tab();
L.print(random(12345));
L.tab();
L.print(analogRead(A0));
L.tab();
L.print(analogRead(A1));
L.tab();
L.print(analogRead(A2));
L.tab();
L.print(analogRead(A3));
L.tab();
L.print(analogRead(A4));
L.tab();
L.print(analogRead(A5));
L.println();
delay(random(100));
}
L.setAutoNewLine(0);
L.repeat(3, '\n');
}
// -- END OF FILE --

View File

@ -1,3 +1,18 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
@ -6,9 +21,10 @@ compile:
# - zero
# - leonardo
- m4
# - esp32 # has other server code
- esp32
# - esp8266
# - mega2560
# - rpipico
libraries:
- "Ethernet"
- "SD"

View File

@ -13,7 +13,10 @@ LineFormatter L;
void setup()
{
Serial.begin(115200);
L.println();
L.println(__FILE__);
L.print("LINEFORMATTER_LIB_VERSION: ");
L.println(LINEFORMATTER_LIB_VERSION);
L.repeat(3, '\n');
test_table_1();

View File

@ -16,6 +16,9 @@ repeat KEYWORD2
setAutoNewLine KEYWORD2
getAutoNewLine KEYWORD2
setTabs KEYWORD2
getTabs KEYWORD2
addTab KEYWORD2
addRelTab KEYWORD2
clearTabs KEYWORD2

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/LineFormatter.git"
},
"version": "0.2.1",
"version": "0.3.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=LineFormatter
version=0.2.1
version=0.3.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Wrapper class for Stream e.g. Serial to enhance layout of tabular data.

View File

@ -33,7 +33,6 @@
#include <ArduinoUnitTests.h>
#include "Arduino.h"
#include "LineFormatter.h"
@ -171,6 +170,31 @@ unittest(test_addTab)
}
unittest(test_setTabs_getTabs)
{
LineFormatter Line;
uint8_t tabs[5] = { 10, 20, 30, 40, 50};
assertTrue(Line.setTabs(tabs, 4));
assertEqual(4, Line.getTabCount());
assertTrue(Line.setTabs(tabs, 3));
assertEqual(3, Line.getTabCount());
assertTrue(Line.setTabs(tabs, 5));
assertEqual(5, Line.getTabCount());
uint8_t tt[5];
uint8_t size = Line.getTabs(tt);
assertEqual(5, size);
for (int i = 0 ; i < size; i++)
{
assertEqual(tt[i], tabs[i]);
}
}
unittest_main()