Skip to content

Commit 8d0d24f

Browse files
committed
Add list_clear() function
1 parent a22f8d3 commit 8d0d24f

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

src/scratch/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ target_sources(scratchcpp
1414
list.cpp
1515
list_p.cpp
1616
list_p.h
17+
list_functions.cpp
18+
list_functions.h
1719
block.cpp
1820
block_p.cpp
1921
block_p.h

src/scratch/list_functions.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
#include <scratchcpp/list.h>
4+
5+
#include "list_functions.h"
6+
7+
using namespace libscratchcpp;
8+
9+
extern "C"
10+
{
11+
void list_clear(List *list)
12+
{
13+
list->clear();
14+
}
15+
}

src/scratch/list_functions.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
#pragma once
4+
5+
namespace libscratchcpp
6+
{
7+
8+
class List;
9+
10+
extern "C"
11+
{
12+
void list_clear(List *list);
13+
}
14+
15+
} // namespace libscratchcpp

test/scratch_classes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ gtest_discover_tests(blockprototype_test)
1616
add_executable(
1717
list_test
1818
list_test.cpp
19+
list_functions_test.cpp
1920
)
2021

2122
target_link_libraries(
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <scratchcpp/list.h>
2+
#include <scratch/list_functions.h>
3+
4+
#include <gtest/gtest.h>
5+
6+
using namespace libscratchcpp;
7+
8+
TEST(ListFunctionsTest, Clear)
9+
{
10+
List list("", "");
11+
list.append(1);
12+
list.append(2);
13+
list.append(3);
14+
15+
list_clear(&list);
16+
}

0 commit comments

Comments
 (0)