Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lib/c/factories.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ SourceFormatDetection detectSourceFormat(const RcnSourceFile* file) {
} else if (strcmp(extension, "json") == 0) {
detection.isSupportedFormat = true;
detection.format = RCN_TEXT_JSON;
} else if (strcmp(extension, "css") == 0) {
detection.isSupportedFormat = true;
detection.format = RCN_TEXT_CSS;
} else if (strcmp(extension, "R") == 0
|| strcmp(extension, "r") == 0) {
// isProgrammingLanguage is false for R format due to missing
Expand Down
12 changes: 11 additions & 1 deletion src/lib/include/reckon/reckon.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ extern "C" {
* The total number of supported text formats, including
* supported programming languages.
*/
#define RECKON_NUM_SUPPORTED_FORMATS 10
#define RECKON_NUM_SUPPORTED_FORMATS 11

/**
* Macro to create a format option bitmask.
Expand Down Expand Up @@ -155,6 +155,11 @@ typedef enum RcnTextFormat {
*/
RCN_TEXT_JSON,

/**
* Text formatted in CSS, as found in files with a '.css' extension.
*/
RCN_TEXT_CSS,

/**
* Source files for the C programming language.
*/
Expand Down Expand Up @@ -731,6 +736,11 @@ typedef enum RcnFormatOption {
*/
RCN_OPT_TEXT_JSON = RECKON_MK_FRMT_OPT(RCN_TEXT_JSON),

/**
* Option to select statistics for CSS text files.
*/
RCN_OPT_TEXT_CSS = RECKON_MK_FRMT_OPT(RCN_TEXT_CSS),

/**
* Option to select statistics for source code files written in
* the C programming language.
Expand Down
8 changes: 8 additions & 0 deletions src/lib/tests/res/misc/sample.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/lib/tests/unit/c/test_statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,31 @@ void testCountResultsJson(void) {
rcnFreeCountStatistics(stats);
}

void testCountResultsCss(void) {
char* path = RECKON_TEST_PATH_RES_BASE "/misc/sample.css";
RcnCountStatistics* stats = rcnCreateCountStatistics(path);
RcnStatOptions options = {
.formats = RCN_OPT_TEXT_CSS
};

rcnCount(stats, options);

TEST_ASSERT_EQUAL_INT(1, stats->count.size);
RcnSourceFile* file = &stats->count.files[0];
RcnCountResultGroup* result = &stats->count.results[0];
TEST_ASSERT_TRUE(result->state.ok);
TEST_ASSERT_EQUAL_INT(RCN_ERR_NONE, result->state.errorCode);
TEST_ASSERT_NULL(result->state.errorMessage);
TEST_ASSERT_EQUAL_STRING("sample.css", file->name);
TEST_ASSERT_TRUE(result->isProcessed);
TEST_ASSERT_EQUAL_INT(0, result->logicalLines);
TEST_ASSERT_EQUAL_INT(8, result->physicalLines);
TEST_ASSERT_EQUAL_INT(17, result->words);
TEST_ASSERT_EQUAL_INT(90, result->characters);
TEST_ASSERT_EQUAL_INT(90, result->sourceSize);
rcnFreeCountStatistics(stats);
}

void testCountResultsR(void) {
char* path = RECKON_TEST_PATH_RES_BASE "/misc/sample.R";
RcnCountStatistics* stats = rcnCreateCountStatistics(path);
Expand Down Expand Up @@ -333,6 +358,7 @@ int main(void) {
RUN_TEST(testCountResultGroupLogicalLineCheckField);
RUN_TEST(testCountResultsXml);
RUN_TEST(testCountResultsJson);
RUN_TEST(testCountResultsCss);
RUN_TEST(testCountResultsR);
return UNITY_END();
}
3 changes: 3 additions & 0 deletions src/scount/c/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ static void prSummaryRows(
case RCN_TEXT_JSON:
label = "JSON";
break;
case RCN_TEXT_CSS:
label = "CSS";
break;
case RCN_LANG_R:
label = "R";
break;
Expand Down
7 changes: 5 additions & 2 deletions src/scount/tests/functionality/res/expected/mixed.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/scount/tests/functionality/res/mixed/sample1.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/scount/tests/functionality/res/mixed/sample2.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.