<commit_before>import std::generic_os::setenv;
import std::generic_os::getenv;
import std::option;

#[test]
fn test_setenv() {
    setenv("NAME", "VALUE");
    assert getenv("NAME") == option::some("VALUE");
}

#[test]
fn test_setenv_overwrite() {
    setenv("NAME", "1");
    setenv("NAME", "2");
    assert getenv("NAME") == option::some("2");
}

// Windows GetEnvironmentVariable requires some extra work to make sure
// the buffer the variable is copied into is the right size
#[test]
fn test_getenv_big() {
    auto s = "";
    auto i = 0;
    while (i < 100) {
        s += "aaaaaaaaaa";
        i += 1;
    }
    setenv("NAME", s);
    assert getenv("NAME") == option::some(s);
}

// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:<commit_msg>Make the setenv tests threadsafe(ish)<commit_after>import std::generic_os::setenv;
import std::generic_os::getenv;
import std::option;

#[test]
fn test_setenv() {
    // NB: Each test of setenv needs to use different variable names or the
    // tests will not be threadsafe
    setenv("NAME1", "VALUE");
    assert getenv("NAME1") == option::some("VALUE");
}

#[test]
fn test_setenv_overwrite() {
    setenv("NAME2", "1");
    setenv("NAME2", "2");
    assert getenv("NAME2") == option::some("2");
}

// Windows GetEnvironmentVariable requires some extra work to make sure
// the buffer the variable is copied into is the right size
#[test]
fn test_getenv_big() {
    auto s = "";
    auto i = 0;
    while (i < 100) {
        s += "aaaaaaaaaa";
        i += 1;
    }
    setenv("NAME3", s);
    assert getenv("NAME3") == option::some(s);
}

// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:
{'fraction_non_alphanumeric': 0.1951588502269289, 'fraction_numerical': 0.017650025214321734, 'mean_word_length': 3.0739219712525667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4496546', 'n_tokens_mistral': 721, 'n_tokens_neox': 702, 'n_words': 191}