()
| 3053 | |
| 3054 | #[test] |
| 3055 | fn test_parse_capacity_limit() { |
| 3056 | const MEMORY_LIMIT: &str = "datafusion.runtime.memory_limit"; |
| 3057 | |
| 3058 | // Valid capacity_limit |
| 3059 | for (limit, want) in [ |
| 3060 | ("0", 0), |
| 3061 | ("1.5K", (1.5 * 1024.0) as usize), |
| 3062 | ("2M", (2f64 * 1024.0 * 1024.0) as usize), |
| 3063 | ("1G", (1f64 * 1024.0 * 1024.0 * 1024.0) as usize), |
| 3064 | ] { |
| 3065 | let have = SessionContext::parse_capacity_limit(MEMORY_LIMIT, limit).unwrap(); |
| 3066 | assert_eq!(want, have); |
| 3067 | } |
| 3068 | |
| 3069 | // Invalid capacity_limit |
| 3070 | for limit in [ |
| 3071 | "1B", |
| 3072 | "1T", |
| 3073 | "", |
| 3074 | " ", |
| 3075 | "XYZG", |
| 3076 | "-1G", |
| 3077 | "infG", |
| 3078 | "-infG", |
| 3079 | "G", |
| 3080 | "1024B", |
| 3081 | "invalid_size", |
| 3082 | ] { |
| 3083 | let have = SessionContext::parse_capacity_limit(MEMORY_LIMIT, limit); |
| 3084 | assert!(have.is_err()); |
| 3085 | assert!(have.unwrap_err().to_string().contains(MEMORY_LIMIT)); |
| 3086 | } |
| 3087 | } |
| 3088 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…