-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-doc] Add basic e2e test #93928
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
219df18
[clang-doc] add basic e2e test
PeterChou1 ccd44f6
[clang][clang-doc] simplify e2e test commands
PeterChou1 d00c4bc
[clang][clang-doc] remove contents in files
PeterChou1 923383c
[clang][clang-doc] make cmake auto copy asset on build
PeterChou1 86638fb
[clang][clang-doc] use copy_directory instead if different
PeterChou1 6aed7d0
[clang][clang-doc] remove fatal condition for failing to generate res…
PeterChou1 922e648
[clang][clang-doc] fix conflicts
PeterChou1 b5680a5
rename clang-doc-project1 to basic-project
PeterChou1 ec188db
[clang][clang-doc] rename sed command for basic-project
PeterChou1 7ca9137
[clang][clang-doc] modify warnings
PeterChou1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"directory": "$test_dir/Inputs/basic-project", | ||
"command": "clang++ -o Calculator.o -I./include ./src/Calculator.cpp", | ||
"file": "./src/Calculator.cpp" | ||
}, | ||
{ | ||
"directory": "$test_dir/Inputs/basic-project", | ||
"command": "clang++ -o Circle.o -I./include ./src/Circle.cpp", | ||
"file": "./src/Circle.cpp" | ||
}, | ||
{ | ||
"directory": "$test_dir/Inputs/basic-project", | ||
"command": "clang++ -o Rectangle.o -I./include ./src/Rectangle.cpp", | ||
"file": "./src/Rectangle.cpp" | ||
} | ||
] |
46 changes: 46 additions & 0 deletions
46
clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Calculator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
/** | ||
* @brief A simple calculator class. | ||
* | ||
* Provides basic arithmetic operations. | ||
*/ | ||
class Calculator { | ||
public: | ||
/** | ||
* @brief Adds two integers. | ||
* | ||
* @param a First integer. | ||
* @param b Second integer. | ||
* @return int The sum of a and b. | ||
*/ | ||
int add(int a, int b); | ||
|
||
/** | ||
* @brief Subtracts the second integer from the first. | ||
* | ||
* @param a First integer. | ||
* @param b Second integer. | ||
* @return int The result of a - b. | ||
*/ | ||
int subtract(int a, int b); | ||
|
||
/** | ||
* @brief Multiplies two integers. | ||
* | ||
* @param a First integer. | ||
* @param b Second integer. | ||
* @return int The product of a and b. | ||
*/ | ||
int multiply(int a, int b); | ||
|
||
/** | ||
* @brief Divides the first integer by the second. | ||
* | ||
* @param a First integer. | ||
* @param b Second integer. | ||
* @return double The result of a / b. | ||
* @throw std::invalid_argument if b is zero. | ||
*/ | ||
double divide(int a, int b); | ||
}; |
35 changes: 35 additions & 0 deletions
35
clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Circle.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include "Shape.h" | ||
|
||
/** | ||
* @brief Circle class derived from Shape. | ||
* | ||
* Represents a circle with a given radius. | ||
*/ | ||
class Circle : public Shape { | ||
public: | ||
/** | ||
* @brief Constructs a new Circle object. | ||
* | ||
* @param radius Radius of the circle. | ||
*/ | ||
Circle(double radius); | ||
|
||
/** | ||
* @brief Calculates the area of the circle. | ||
* | ||
* @return double The area of the circle. | ||
*/ | ||
double area() const override; | ||
|
||
/** | ||
* @brief Calculates the perimeter of the circle. | ||
* | ||
* @return double The perimeter of the circle. | ||
*/ | ||
double perimeter() const override; | ||
|
||
private: | ||
double radius_; ///< Radius of the circle. | ||
}; |
37 changes: 37 additions & 0 deletions
37
clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Rectangle.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include "Shape.h" | ||
|
||
/** | ||
* @brief Rectangle class derived from Shape. | ||
* | ||
* Represents a rectangle with a given width and height. | ||
*/ | ||
class Rectangle : public Shape { | ||
public: | ||
/** | ||
* @brief Constructs a new Rectangle object. | ||
* | ||
* @param width Width of the rectangle. | ||
* @param height Height of the rectangle. | ||
*/ | ||
Rectangle(double width, double height); | ||
|
||
/** | ||
* @brief Calculates the area of the rectangle. | ||
* | ||
* @return double The area of the rectangle. | ||
*/ | ||
double area() const override; | ||
|
||
/** | ||
* @brief Calculates the perimeter of the rectangle. | ||
* | ||
* @return double The perimeter of the rectangle. | ||
*/ | ||
double perimeter() const override; | ||
|
||
private: | ||
double width_; ///< Width of the rectangle. | ||
double height_; ///< Height of the rectangle. | ||
}; |
30 changes: 30 additions & 0 deletions
30
clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Shape.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
/** | ||
* @brief Abstract base class for shapes. | ||
* | ||
* Provides a common interface for different types of shapes. | ||
*/ | ||
class Shape { | ||
public: | ||
/** | ||
* @brief Virtual destructor. | ||
*/ | ||
virtual ~Shape() {} | ||
|
||
/** | ||
* @brief Calculates the area of the shape. | ||
* | ||
* @return double The area of the shape. | ||
*/ | ||
virtual double area() const = 0; | ||
|
||
/** | ||
* @brief Calculates the perimeter of the shape. | ||
* | ||
* @return double The perimeter of the shape. | ||
*/ | ||
virtual double perimeter() const = 0; | ||
}; | ||
|
||
|
21 changes: 21 additions & 0 deletions
21
clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "Calculator.h" | ||
#include <stdexcept> | ||
|
||
int Calculator::add(int a, int b) { | ||
return a + b; | ||
} | ||
|
||
int Calculator::subtract(int a, int b) { | ||
return a - b; | ||
} | ||
|
||
int Calculator::multiply(int a, int b) { | ||
return a * b; | ||
} | ||
|
||
double Calculator::divide(int a, int b) { | ||
if (b == 0) { | ||
throw std::invalid_argument("Division by zero"); | ||
} | ||
return static_cast<double>(a) / b; | ||
} |
11 changes: 11 additions & 0 deletions
11
clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Circle.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "Circle.h" | ||
|
||
Circle::Circle(double radius) : radius_(radius) {} | ||
|
||
double Circle::area() const { | ||
return 3.141 * radius_ * radius_; | ||
} | ||
|
||
double Circle::perimeter() const { | ||
return 3.141 * radius_; | ||
} |
12 changes: 12 additions & 0 deletions
12
clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Rectangle.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "Rectangle.h" | ||
|
||
Rectangle::Rectangle(double width, double height) | ||
: width_(width), height_(height) {} | ||
|
||
double Rectangle::area() const { | ||
return width_ * height_; | ||
} | ||
|
||
double Rectangle::perimeter() const { | ||
return 2 * (width_ + height_); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests must be freestanding and cannot include system headers.