-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from harshfeudal/develop
[Merge]: Done fixing
- Loading branch information
Showing
9 changed files
with
214 additions
and
137 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
*.h linguist-language=C++ | ||
*.cpp linguist-language=C++ |
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
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
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 @@ | ||
# Security Policy | ||
|
||
## Supported Versions | ||
|
||
| Name | Version | Supported | | ||
| ---------------------- | ------------ | ------------------ | | ||
| dotenv.h | 1.2.0 | [x] | | ||
|
||
## Reporting a Vulnerability | ||
|
||
To report a vulnerability please contact the development team by using Github Issue or Discord server. We will discuss and fix it ASAP. Once the fix has been put into a release version, the vulnerability will be made public. |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version: 1.1.0.{build} | ||
version: 1.2.0.{build} | ||
image: Visual Studio 2022 | ||
environment: | ||
matrix: | ||
|
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
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 |
---|---|---|
@@ -1,7 +1,17 @@ | ||
# Normal test: | ||
MY_BOOL=true | ||
MY_INT=42 | ||
MY_LONG=-123456789012345 | ||
MY_STRING="Hello, world!" | ||
MY_STRING='Hello World!' | ||
MY_EMPTY_STRING= # with a space | ||
|
||
# Special string: | ||
MY_HARSHFEUDAL="\n-----Harshfeudal-----\n\t\"Hello\"\n-----Complete!-----\n" # This is comment, it will not log | ||
MY_HASH="something-with-a-#-hash" | ||
MY_SPACING="\nNew Line\tTabs\n-------Hey!\r\"What\"" | ||
MY_SPACING="\nNew Line\tTabs\n-------Hey!\r\"What\"" | ||
|
||
# Complex: | ||
MY_VAR_1="Hi" | ||
MY_VAR_2="Harshfeudal" | ||
|
||
MY_COMPLEX=${MY_VAR_1} ${MY_VAR_2} |
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 |
---|---|---|
@@ -1,123 +1,34 @@ | ||
#include <dotenv/dotenv.h> | ||
|
||
#include <iostream> | ||
#include <chrono> | ||
|
||
class Timer | ||
{ | ||
public: | ||
Timer() { m_StartTimepoint = std::chrono::high_resolution_clock::now(); } | ||
~Timer() { Stop(); } | ||
|
||
void Stop() { | ||
auto endTimepoint = std::chrono::high_resolution_clock::now(); | ||
|
||
auto start = std::chrono::time_point_cast<std::chrono::microseconds>(m_StartTimepoint).time_since_epoch().count(); | ||
auto end = std::chrono::time_point_cast<std::chrono::microseconds>(endTimepoint).time_since_epoch().count(); | ||
|
||
auto duration = end - start; | ||
double ms = duration * 0.001; | ||
|
||
std::cout << duration << "us (" << ms << "ms)\n"; | ||
} | ||
|
||
private: | ||
std::chrono::time_point<std::chrono::high_resolution_clock> m_StartTimepoint; | ||
}; | ||
#include "test.h" | ||
|
||
void run_test(const std::string& name) { | ||
std::cout << name << " test: " << std::endl; | ||
{ | ||
Timer timer; | ||
const char* my_var = std::getenv(("MY_" + name).c_str()); | ||
if (my_var) { | ||
std::cout << "MY_RESULT=" << my_var << std::endl; | ||
} | ||
else { | ||
std::cerr << "MY_RESULT not found in environment" << std::endl; | ||
} | ||
} | ||
std::cout << std::endl; | ||
} | ||
|
||
int main() { | ||
dotenv::load("./test/.env"); | ||
|
||
std::cout << "Bool test: " << std::endl; | ||
{ | ||
Timer timer; | ||
const char* my_var = std::getenv("MY_BOOL"); | ||
if (my_var) { | ||
std::cout << "MY_RESULT=" << my_var << std::endl; | ||
} | ||
else { | ||
std::cerr << "MY_RESULT not found in environment" << std::endl; | ||
} | ||
} | ||
std::cout << std::endl; | ||
|
||
std::cout << "Int test: " << std::endl; | ||
{ | ||
Timer timer; | ||
const char* my_var = std::getenv("MY_INT"); | ||
if (my_var) { | ||
std::cout << "MY_RESULT=" << my_var << std::endl; | ||
} | ||
else { | ||
std::cerr << "MY_RESULT not found in environment" << std::endl; | ||
} | ||
} | ||
std::cout << std::endl; | ||
|
||
std::cout << "Long test: " << std::endl; | ||
{ | ||
Timer timer; | ||
const char* my_var = std::getenv("MY_LONG"); | ||
if (my_var) { | ||
std::cout << "MY_RESULT=" << my_var << std::endl; | ||
} | ||
else { | ||
std::cerr << "MY_RESULT not found in environment" << std::endl; | ||
} | ||
} | ||
std::cout << std::endl; | ||
|
||
std::cout << "String test: " << std::endl; | ||
{ | ||
Timer timer; | ||
const char* my_var = std::getenv("MY_STRING"); | ||
if (my_var) { | ||
std::cout << "MY_RESULT=" << my_var << std::endl; | ||
} | ||
else { | ||
std::cerr << "MY_RESULT not found in environment" << std::endl; | ||
} | ||
} | ||
std::cout << std::endl; | ||
|
||
std::cout << "Harshfeudal test: " << std::endl; | ||
{ | ||
Timer timer; | ||
const char* my_var = std::getenv("MY_HARSHFEUDAL"); | ||
if (my_var) { | ||
std::cout << "MY_RESULT=" << my_var << std::endl; | ||
} | ||
else { | ||
std::cerr << "MY_RESULT not found in environment" << std::endl; | ||
} | ||
} | ||
std::cout << std::endl; | ||
|
||
std::cout << "Hash test: " << std::endl; | ||
{ | ||
Timer timer; | ||
const char* my_var = std::getenv("MY_HASH"); | ||
if (my_var) { | ||
std::cout << "MY_RESULT=" << my_var << std::endl; | ||
} | ||
else { | ||
std::cerr << "MY_RESULT not found in environment" << std::endl; | ||
} | ||
} | ||
std::cout << std::endl; | ||
|
||
std::cout << "Spacing test: " << std::endl; | ||
{ | ||
Timer timer; | ||
const char* my_var = std::getenv("MY_SPACING"); | ||
if (my_var) { | ||
std::cout << "MY_RESULT=" << my_var << std::endl; | ||
} | ||
else { | ||
std::cerr << "MY_RESULT not found in environment" << std::endl; | ||
} | ||
} | ||
std::cout << std::endl; | ||
|
||
return 0; | ||
} | ||
dotenv::load("./test/.env"); | ||
|
||
run_test("BOOL"); | ||
run_test("INT"); | ||
run_test("LONG"); | ||
run_test("STRING"); | ||
run_test("HARSHFEUDAL"); | ||
run_test("HASH"); | ||
run_test("SPACING"); | ||
run_test("COMPLEX"); | ||
run_test("EMPTY_STRING"); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.